|
plez help!counting letters in string
i tried this but it says error in ' If MyArray(i) = "a" ', that it was out of array bound. did i missing something?
Function MyLetter()
Dim aCount As Integer = 0
Dim bCount As Integer = 0
Dim cCount As Integer = 0
'letter = window.prompt('Please enter a letter', '');
'length = letter.length;
'var my_array = letter.split("");
Dim MyString = txtLetter.Text.Length
Dim MyArray = "aabbcc"
Dim i As Integer
For i = 0 To MyString - 1 Step i + 1
If MyArray(i) = "a" Then
aCount = aCount + 1
ElseIf MyArray(i) = "b" Then
bCount = bCount + 1
ElseIf MyArray(i) = "c" Then
cCount = cCount + 1
End If
Next
Label1.Text = aCount
End Function
|