Подсчет количества опред. буквы.
Выглядеть должно примерно так:
1)Нажимаем по кнопке
2)Видим окно ImputBox
3)Вводим предложение
4) Видим количество букв А ( через Print )
Буду благодарен, ибо сам так и не разобрался, хотя угробил часов 6.
Это школьное задание. Прошу сделать все банально и примитивно, а то мну не поверят. =)
Спасибо
Код:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String
Dim i As Integer
On Error Resume Next
s = InputBox("Ведите предложенье")
i = 0
If s(0) <> "А" Then i = i + 1
If s(1) <> "А" Then i = i + 1
If s(2) <> "А" Then i = i + 1
If s(3) <> "А" Then i = i + 1
If s(4) <> "А" Then i = i + 1
If s(5) <> "А" Then i = i + 1
If s(6) <> "А" Then i = i + 1
If s(7) <> "А" Then i = i + 1
If s(8) <> "А" Then i = i + 1
If s(9) <> "А" Then i = i + 1
If s(10) <> "А" Then i = i + 1
If s(11) <> "А" Then i = i + 1
If s(12) <> "А" Then i = i + 1
If s(13) <> "А" Then i = i + 1
If s(14) <> "А" Then i = i + 1
If s(15) <> "А" Then i = i + 1
If s(16) <> "А" Then i = i + 1
If s(17) <> "А" Then i = i + 1
If s(18) <> "А" Then i = i + 1
If s(19) <> "А" Then i = i + 1
If s(20) <> "А" Then i = i + 1
If s(21) <> "А" Then i = i + 1
If s(22) <> "А" Then i = i + 1
If s(23) <> "А" Then i = i + 1
If s(24) <> "А" Then i = i + 1
If s(25) <> "А" Then i = i + 1
If s(26) <> "А" Then i = i + 1
If s(27) <> "А" Then i = i + 1
If s(28) <> "А" Then i = i + 1
If s(29) <> "А" Then i = i + 1
If s(30) <> "А" Then i = i + 1
If s(31) <> "А" Then i = i + 1
If s(32) <> "А" Then i = i + 1
If s(33) <> "А" Then i = i + 1
If s(34) <> "А" Then i = i + 1
If s(35) <> "А" Then i = i + 1
If s(36) <> "А" Then i = i + 1
If s(37) <> "А" Then i = i + 1
If s(38) <> "А" Then i = i + 1
If s(39) <> "А" Then i = i + 1
If s(40) <> "А" Then i = i + 1
If s(41) <> "А" Then i = i + 1
If s(42) <> "А" Then i = i + 1
If s(43) <> "А" Then i = i + 1
If s(44) <> "А" Then i = i + 1
If s(45) <> "А" Then i = i + 1
If s(46) <> "А" Then i = i + 1
If s(47) <> "А" Then i = i + 1
If s(48) <> "А" Then i = i + 1
If s(49) <> "А" Then i = i + 1
If s(50) <> "А" Then i = i + 1
If s(51) <> "А" Then i = i + 1
If s(52) <> "А" Then i = i + 1
If s(53) <> "А" Then i = i + 1
If s(54) <> "А" Then i = i + 1
If s(55) <> "А" Then i = i + 1
If s(56) <> "А" Then i = i + 1
If s(57) <> "А" Then i = i + 1
If s(58) <> "А" Then i = i + 1
If s(59) <> "А" Then i = i + 1
If s(60) <> "А" Then i = i + 1
If s(61) <> "А" Then i = i + 1
If s(62) <> "А" Then i = i + 1
If s(63) <> "А" Then i = i + 1
If s(64) <> "А" Then i = i + 1
If s(65) <> "А" Then i = i + 1
If s(66) <> "А" Then i = i + 1
If s(67) <> "А" Then i = i + 1
If s(68) <> "А" Then i = i + 1
If s(69) <> "А" Then i = i + 1
If s(70) <> "А" Then i = i + 1
If s(71) <> "А" Then i = i + 1
If s(72) <> "А" Then i = i + 1
If s(73) <> "А" Then i = i + 1
If s(74) <> "А" Then i = i + 1
If s(75) <> "А" Then i = i + 1
If s(76) <> "А" Then i = i + 1
If s(77) <> "А" Then i = i + 1
If s(78) <> "А" Then i = i + 1
If s(79) <> "А" Then i = i + 1
If s(80) <> "А" Then i = i + 1
If s(81) <> "А" Then i = i + 1
If s(82) <> "А" Then i = i + 1
If s(83) <> "А" Then i = i + 1
If s(84) <> "А" Then i = i + 1
If s(85) <> "А" Then i = i + 1
If s(86) <> "А" Then i = i + 1
If s(87) <> "А" Then i = i + 1
If s(88) <> "А" Then i = i + 1
If s(89) <> "А" Then i = i + 1
If s(90) <> "А" Then i = i + 1
If s(91) <> "А" Then i = i + 1
If s(92) <> "А" Then i = i + 1
If s(93) <> "А" Then i = i + 1
If s(94) <> "А" Then i = i + 1
If s(95) <> "А" Then i = i + 1
If s(96) <> "А" Then i = i + 1
If s(97) <> "А" Then i = i + 1
If s(98) <> "А" Then i = i + 1
If s(99) <> "А" Then i = i + 1
If s(100) <> "А" Then i = i + 1
i = 101 - i
If i = 0 Then MessageBox.Show("0")
If i = 1 Then MessageBox.Show("1")
If i = 2 Then MessageBox.Show("2")
If i = 3 Then MessageBox.Show("3")
If i = 4 Then MessageBox.Show("4")
If i = 5 Then MessageBox.Show("5")
If i = 6 Then MessageBox.Show("6")
If i = 7 Then MessageBox.Show("7")
If i = 8 Then MessageBox.Show("8")
If i = 9 Then MessageBox.Show("9")
If i = 10 Then MessageBox.Show("10")
If i = 11 Then MessageBox.Show("11")
If i = 12 Then MessageBox.Show("12")
If i = 13 Then MessageBox.Show("13")
If i = 14 Then MessageBox.Show("14")
If i = 15 Then MessageBox.Show("15")
If i = 16 Then MessageBox.Show("16")
If i = 17 Then MessageBox.Show("17")
If i = 18 Then MessageBox.Show("18")
If i = 19 Then MessageBox.Show("19")
If i = 20 Then MessageBox.Show("20")
If i = 21 Then MessageBox.Show("21")
If i = 22 Then MessageBox.Show("22")
If i = 23 Then MessageBox.Show("23")
If i = 24 Then MessageBox.Show("24")
If i = 25 Then MessageBox.Show("25")
If i = 26 Then MessageBox.Show("26")
If i = 27 Then MessageBox.Show("27")
If i = 28 Then MessageBox.Show("28")
If i = 29 Then MessageBox.Show("29")
If i = 30 Then MessageBox.Show("30")
If i = 31 Then MessageBox.Show("31")
If i = 32 Then MessageBox.Show("32")
If i = 33 Then MessageBox.Show("33")
If i = 34 Then MessageBox.Show("34")
If i = 35 Then MessageBox.Show("35")
If i = 36 Then MessageBox.Show("36")
If i = 37 Then MessageBox.Show("37")
If i = 38 Then MessageBox.Show("38")
If i = 39 Then MessageBox.Show("39")
If i = 40 Then MessageBox.Show("40")
If i = 41 Then MessageBox.Show("41")
If i = 42 Then MessageBox.Show("42")
If i = 43 Then MessageBox.Show("43")
If i = 44 Then MessageBox.Show("44")
If i = 45 Then MessageBox.Show("45")
If i = 46 Then MessageBox.Show("46")
If i = 47 Then MessageBox.Show("47")
If i = 48 Then MessageBox.Show("48")
If i = 49 Then MessageBox.Show("49")
If i = 50 Then MessageBox.Show("50")
If i = 51 Then MessageBox.Show("51")
If i = 52 Then MessageBox.Show("52")
If i = 53 Then MessageBox.Show("53")
If i = 54 Then MessageBox.Show("54")
If i = 55 Then MessageBox.Show("55")
If i = 56 Then MessageBox.Show("56")
If i = 57 Then MessageBox.Show("57")
If i = 58 Then MessageBox.Show("58")
If i = 59 Then MessageBox.Show("59")
If i = 60 Then MessageBox.Show("60")
If i = 61 Then MessageBox.Show("61")
If i = 62 Then MessageBox.Show("62")
If i = 63 Then MessageBox.Show("63")
If i = 64 Then MessageBox.Show("64")
If i = 65 Then MessageBox.Show("65")
If i = 66 Then MessageBox.Show("66")
If i = 67 Then MessageBox.Show("67")
If i = 68 Then MessageBox.Show("68")
If i = 69 Then MessageBox.Show("69")
If i = 70 Then MessageBox.Show("70")
If i = 71 Then MessageBox.Show("71")
If i = 72 Then MessageBox.Show("72")
If i = 73 Then MessageBox.Show("73")
If i = 74 Then MessageBox.Show("74")
If i = 75 Then MessageBox.Show("75")
If i = 76 Then MessageBox.Show("76")
If i = 77 Then MessageBox.Show("77")
If i = 78 Then MessageBox.Show("78")
If i = 79 Then MessageBox.Show("79")
If i = 80 Then MessageBox.Show("80")
If i = 81 Then MessageBox.Show("81")
If i = 82 Then MessageBox.Show("82")
If i = 83 Then MessageBox.Show("83")
If i = 84 Then MessageBox.Show("84")
If i = 85 Then MessageBox.Show("85")
If i = 86 Then MessageBox.Show("86")
If i = 87 Then MessageBox.Show("87")
If i = 88 Then MessageBox.Show("88")
If i = 89 Then MessageBox.Show("89")
If i = 90 Then MessageBox.Show("90")
If i = 91 Then MessageBox.Show("91")
If i = 92 Then MessageBox.Show("92")
If i = 93 Then MessageBox.Show("93")
If i = 94 Then MessageBox.Show("94")
If i = 95 Then MessageBox.Show("95")
If i = 96 Then MessageBox.Show("96")
If i = 97 Then MessageBox.Show("97")
If i = 98 Then MessageBox.Show("98")
If i = 99 Then MessageBox.Show("99")
If i = 100 Then MessageBox.Show("100")
End Sub
Dim s As String
Dim i As Integer
On Error Resume Next
s = InputBox("Ведите предложенье")
i = 0
If s(0) <> "А" Then i = i + 1
If s(1) <> "А" Then i = i + 1
If s(2) <> "А" Then i = i + 1
If s(3) <> "А" Then i = i + 1
If s(4) <> "А" Then i = i + 1
If s(5) <> "А" Then i = i + 1
If s(6) <> "А" Then i = i + 1
If s(7) <> "А" Then i = i + 1
If s(8) <> "А" Then i = i + 1
If s(9) <> "А" Then i = i + 1
If s(10) <> "А" Then i = i + 1
If s(11) <> "А" Then i = i + 1
If s(12) <> "А" Then i = i + 1
If s(13) <> "А" Then i = i + 1
If s(14) <> "А" Then i = i + 1
If s(15) <> "А" Then i = i + 1
If s(16) <> "А" Then i = i + 1
If s(17) <> "А" Then i = i + 1
If s(18) <> "А" Then i = i + 1
If s(19) <> "А" Then i = i + 1
If s(20) <> "А" Then i = i + 1
If s(21) <> "А" Then i = i + 1
If s(22) <> "А" Then i = i + 1
If s(23) <> "А" Then i = i + 1
If s(24) <> "А" Then i = i + 1
If s(25) <> "А" Then i = i + 1
If s(26) <> "А" Then i = i + 1
If s(27) <> "А" Then i = i + 1
If s(28) <> "А" Then i = i + 1
If s(29) <> "А" Then i = i + 1
If s(30) <> "А" Then i = i + 1
If s(31) <> "А" Then i = i + 1
If s(32) <> "А" Then i = i + 1
If s(33) <> "А" Then i = i + 1
If s(34) <> "А" Then i = i + 1
If s(35) <> "А" Then i = i + 1
If s(36) <> "А" Then i = i + 1
If s(37) <> "А" Then i = i + 1
If s(38) <> "А" Then i = i + 1
If s(39) <> "А" Then i = i + 1
If s(40) <> "А" Then i = i + 1
If s(41) <> "А" Then i = i + 1
If s(42) <> "А" Then i = i + 1
If s(43) <> "А" Then i = i + 1
If s(44) <> "А" Then i = i + 1
If s(45) <> "А" Then i = i + 1
If s(46) <> "А" Then i = i + 1
If s(47) <> "А" Then i = i + 1
If s(48) <> "А" Then i = i + 1
If s(49) <> "А" Then i = i + 1
If s(50) <> "А" Then i = i + 1
If s(51) <> "А" Then i = i + 1
If s(52) <> "А" Then i = i + 1
If s(53) <> "А" Then i = i + 1
If s(54) <> "А" Then i = i + 1
If s(55) <> "А" Then i = i + 1
If s(56) <> "А" Then i = i + 1
If s(57) <> "А" Then i = i + 1
If s(58) <> "А" Then i = i + 1
If s(59) <> "А" Then i = i + 1
If s(60) <> "А" Then i = i + 1
If s(61) <> "А" Then i = i + 1
If s(62) <> "А" Then i = i + 1
If s(63) <> "А" Then i = i + 1
If s(64) <> "А" Then i = i + 1
If s(65) <> "А" Then i = i + 1
If s(66) <> "А" Then i = i + 1
If s(67) <> "А" Then i = i + 1
If s(68) <> "А" Then i = i + 1
If s(69) <> "А" Then i = i + 1
If s(70) <> "А" Then i = i + 1
If s(71) <> "А" Then i = i + 1
If s(72) <> "А" Then i = i + 1
If s(73) <> "А" Then i = i + 1
If s(74) <> "А" Then i = i + 1
If s(75) <> "А" Then i = i + 1
If s(76) <> "А" Then i = i + 1
If s(77) <> "А" Then i = i + 1
If s(78) <> "А" Then i = i + 1
If s(79) <> "А" Then i = i + 1
If s(80) <> "А" Then i = i + 1
If s(81) <> "А" Then i = i + 1
If s(82) <> "А" Then i = i + 1
If s(83) <> "А" Then i = i + 1
If s(84) <> "А" Then i = i + 1
If s(85) <> "А" Then i = i + 1
If s(86) <> "А" Then i = i + 1
If s(87) <> "А" Then i = i + 1
If s(88) <> "А" Then i = i + 1
If s(89) <> "А" Then i = i + 1
If s(90) <> "А" Then i = i + 1
If s(91) <> "А" Then i = i + 1
If s(92) <> "А" Then i = i + 1
If s(93) <> "А" Then i = i + 1
If s(94) <> "А" Then i = i + 1
If s(95) <> "А" Then i = i + 1
If s(96) <> "А" Then i = i + 1
If s(97) <> "А" Then i = i + 1
If s(98) <> "А" Then i = i + 1
If s(99) <> "А" Then i = i + 1
If s(100) <> "А" Then i = i + 1
i = 101 - i
If i = 0 Then MessageBox.Show("0")
If i = 1 Then MessageBox.Show("1")
If i = 2 Then MessageBox.Show("2")
If i = 3 Then MessageBox.Show("3")
If i = 4 Then MessageBox.Show("4")
If i = 5 Then MessageBox.Show("5")
If i = 6 Then MessageBox.Show("6")
If i = 7 Then MessageBox.Show("7")
If i = 8 Then MessageBox.Show("8")
If i = 9 Then MessageBox.Show("9")
If i = 10 Then MessageBox.Show("10")
If i = 11 Then MessageBox.Show("11")
If i = 12 Then MessageBox.Show("12")
If i = 13 Then MessageBox.Show("13")
If i = 14 Then MessageBox.Show("14")
If i = 15 Then MessageBox.Show("15")
If i = 16 Then MessageBox.Show("16")
If i = 17 Then MessageBox.Show("17")
If i = 18 Then MessageBox.Show("18")
If i = 19 Then MessageBox.Show("19")
If i = 20 Then MessageBox.Show("20")
If i = 21 Then MessageBox.Show("21")
If i = 22 Then MessageBox.Show("22")
If i = 23 Then MessageBox.Show("23")
If i = 24 Then MessageBox.Show("24")
If i = 25 Then MessageBox.Show("25")
If i = 26 Then MessageBox.Show("26")
If i = 27 Then MessageBox.Show("27")
If i = 28 Then MessageBox.Show("28")
If i = 29 Then MessageBox.Show("29")
If i = 30 Then MessageBox.Show("30")
If i = 31 Then MessageBox.Show("31")
If i = 32 Then MessageBox.Show("32")
If i = 33 Then MessageBox.Show("33")
If i = 34 Then MessageBox.Show("34")
If i = 35 Then MessageBox.Show("35")
If i = 36 Then MessageBox.Show("36")
If i = 37 Then MessageBox.Show("37")
If i = 38 Then MessageBox.Show("38")
If i = 39 Then MessageBox.Show("39")
If i = 40 Then MessageBox.Show("40")
If i = 41 Then MessageBox.Show("41")
If i = 42 Then MessageBox.Show("42")
If i = 43 Then MessageBox.Show("43")
If i = 44 Then MessageBox.Show("44")
If i = 45 Then MessageBox.Show("45")
If i = 46 Then MessageBox.Show("46")
If i = 47 Then MessageBox.Show("47")
If i = 48 Then MessageBox.Show("48")
If i = 49 Then MessageBox.Show("49")
If i = 50 Then MessageBox.Show("50")
If i = 51 Then MessageBox.Show("51")
If i = 52 Then MessageBox.Show("52")
If i = 53 Then MessageBox.Show("53")
If i = 54 Then MessageBox.Show("54")
If i = 55 Then MessageBox.Show("55")
If i = 56 Then MessageBox.Show("56")
If i = 57 Then MessageBox.Show("57")
If i = 58 Then MessageBox.Show("58")
If i = 59 Then MessageBox.Show("59")
If i = 60 Then MessageBox.Show("60")
If i = 61 Then MessageBox.Show("61")
If i = 62 Then MessageBox.Show("62")
If i = 63 Then MessageBox.Show("63")
If i = 64 Then MessageBox.Show("64")
If i = 65 Then MessageBox.Show("65")
If i = 66 Then MessageBox.Show("66")
If i = 67 Then MessageBox.Show("67")
If i = 68 Then MessageBox.Show("68")
If i = 69 Then MessageBox.Show("69")
If i = 70 Then MessageBox.Show("70")
If i = 71 Then MessageBox.Show("71")
If i = 72 Then MessageBox.Show("72")
If i = 73 Then MessageBox.Show("73")
If i = 74 Then MessageBox.Show("74")
If i = 75 Then MessageBox.Show("75")
If i = 76 Then MessageBox.Show("76")
If i = 77 Then MessageBox.Show("77")
If i = 78 Then MessageBox.Show("78")
If i = 79 Then MessageBox.Show("79")
If i = 80 Then MessageBox.Show("80")
If i = 81 Then MessageBox.Show("81")
If i = 82 Then MessageBox.Show("82")
If i = 83 Then MessageBox.Show("83")
If i = 84 Then MessageBox.Show("84")
If i = 85 Then MessageBox.Show("85")
If i = 86 Then MessageBox.Show("86")
If i = 87 Then MessageBox.Show("87")
If i = 88 Then MessageBox.Show("88")
If i = 89 Then MessageBox.Show("89")
If i = 90 Then MessageBox.Show("90")
If i = 91 Then MessageBox.Show("91")
If i = 92 Then MessageBox.Show("92")
If i = 93 Then MessageBox.Show("93")
If i = 94 Then MessageBox.Show("94")
If i = 95 Then MessageBox.Show("95")
If i = 96 Then MessageBox.Show("96")
If i = 97 Then MessageBox.Show("97")
If i = 98 Then MessageBox.Show("98")
If i = 99 Then MessageBox.Show("99")
If i = 100 Then MessageBox.Show("100")
End Sub
Код:
Option Explicit
Dim strYourText As String
Dim strFind As String
Dim intFind As Integer
Dim i As Long
Private Sub btnEnd_Click()
End
End Sub
Private Sub btnStart_Click()
intFind = 0
' чистим форму
Form1.Cls
strYourText = "Это есть ваш текст AAAA"
' что будим искать(символ)
strFind = InputBox("Поиск символа")
' Len(strYourText) определить длину текста
For i = 1 To Len(strYourText)
If Mid(strYourText, i, 1) = strFind Then
' сколько раз нашел символ
intFind = intFind + 1
End If
Next i
' печатать на форме
Print " Найдено " + strFind + Str(intFind) + " раз(а)"
End Sub
Dim strYourText As String
Dim strFind As String
Dim intFind As Integer
Dim i As Long
Private Sub btnEnd_Click()
End
End Sub
Private Sub btnStart_Click()
intFind = 0
' чистим форму
Form1.Cls
strYourText = "Это есть ваш текст AAAA"
' что будим искать(символ)
strFind = InputBox("Поиск символа")
' Len(strYourText) определить длину текста
For i = 1 To Len(strYourText)
If Mid(strYourText, i, 1) = strFind Then
' сколько раз нашел символ
intFind = intFind + 1
End If
Next i
' печатать на форме
Print " Найдено " + strFind + Str(intFind) + " раз(а)"
End Sub