View Single Post
Old 03-02-2006, 06:24 PM   #1 (permalink)
deehanie
Registered User
 
Join Date: Mar 2006
Posts: 2
deehanie is on a distinguished road
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
deehanie is offline   Reply With Quote