Write a program in which a text string of Latin letters and auxiliary characters is first entered upon request. It is required to replace in it all the occurrences of the small letter βaβ by 1, the small letter βbβ by 22, βcβ - by 333. In the new line, count the number of digits. The final line and the number of digits to issue on the screen. It turned out just that ... but nothing goes
Dim Len, k,m,n, i As Integer Dim Str, StrNew As String Dim Ch As Char Str = InputBox("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΡΡΠΎΠΊΡ ΠΈΠ· Π»Π°ΡΠΈΠ½ΡΠΊΠΈΡ
Π±ΡΠΊΠ² ΠΈ Π²ΡΠΏΠΎΠΌΠΎΠ³Π°ΡΠ΅Π»ΡΠ½ΡΡ
ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ²") For i = 1 To Len 'ΠΡΠΎΡ
ΠΎΠ΄ ΠΏΠΎ ΡΡΡΠΎΠΊΠ΅ Str Ch = Mid(Str, i, 1) 'ΠΡΠ΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΎΡΠ΅ΡΠ΅Π΄Π½ΠΎΠ³ΠΎ ΡΠΈΠΌΠ²ΠΎΠ»Π° If Ch = "a" Then k = k + 1 ' Π‘ΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Π° Ρ Π±ΡΠΊΠ²ΠΎΠΉ Π° ΠΈ ΠΏΠΎΠ΄ΡΡΠ΅Ρ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ If Ch = "b" Then n = m + 22 ' Π‘ΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Π° Ρ Π±ΡΠΊΠ²ΠΎΠΉ b ΠΈ ΠΏΠΎΠ΄ΡΡΠ΅Ρ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ If Ch = "c" Then n = n + 333 ' Π‘ΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΡΠΈΠΌΠ²ΠΎΠ»Π° Ρ Π±ΡΠΊΠ²ΠΎΠΉ c ΠΈ ΠΏΠΎΠ΄ΡΡΠ΅Ρ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ Next i MsgBox(" Π§ΠΈΡΠ»ΠΎ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ ΠΌΠ°Π»ΠΎΠΉ Π»Π°ΡΠΈΠ½ΡΠΊΠΎΠΉ Π±ΡΠΊΠ²Ρ Π° ΡΠ°Π²Π½ΠΎ ") MsgBox(" Π§ΠΈΡΠ»ΠΎ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ ΠΌΠ°Π»ΠΎΠΉ Π»Π°ΡΠΈΠ½ΡΠΊΠΎΠΉ Π±ΡΠΊΠ²Ρ b ΡΠ°Π²Π½ΠΎ ") MsgBox(" Π§ΠΈΡΠ»ΠΎ Π²Ρ
ΠΎΠΆΠ΄Π΅Π½ΠΈΠΉ ΠΌΠ°Π»ΠΎΠΉ Π»Π°ΡΠΈΠ½ΡΠΊΠΎΠΉ Π±ΡΠΊΠ²Ρ c ΡΠ°Π²Π½ΠΎ ") End
Ch = Mid(Str, i, 1)
received another character,If Ch = "a"
checked if it was not"a"
, but what doesk = k + 1
gok = k + 1
and what do you really need? And theLen
value is not calculated anywhere, where can it be correct? - VladD