Hi all,
I am writing a form to take in a string and count Vowels, Consonants and spaces.
Here is what i have so far but i seem to be running into an issue.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan.Click
Dim Input As String
Dim Vcount, Ccount, Scount As Integer
Dim i As Integer
Dim Check As String
Dim letter As String
Input = (txtinput.Text)
Vcount = 0
Ccount = 0
Scount = 0
For i = Len(Input) To 1
Check = Mid(Input, i, 1)
letter = Check
If letter = "A" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "E" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "I" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "O" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "U" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "B" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "C" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "D" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "F" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "G" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "H" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "J" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "K" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "L" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "M" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "N" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "P" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Q" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "R" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "S" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "T" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "V" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "W" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "X" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Y" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Z" Then
Ccount += 1
txtC.Text = Ccount
Else
Scount += 1
txtS.Text = Scount
End If
Next i
End Sub
End Class
I have a gut instinct that it is to do with my iteration loop, either way I know im close but I am stuck in the mud on this one,
Any help would be appreciated,
Cheers,
R
I am writing a form to take in a string and count Vowels, Consonants and spaces.
Here is what i have so far but i seem to be running into an issue.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan.Click
Dim Input As String
Dim Vcount, Ccount, Scount As Integer
Dim i As Integer
Dim Check As String
Dim letter As String
Input = (txtinput.Text)
Vcount = 0
Ccount = 0
Scount = 0
For i = Len(Input) To 1
Check = Mid(Input, i, 1)
letter = Check
If letter = "A" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "E" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "I" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "O" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "U" Then
Vcount += 1
txtV.Text = Vcount
ElseIf letter = "B" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "C" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "D" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "F" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "G" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "H" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "J" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "K" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "L" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "M" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "N" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "P" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Q" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "R" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "S" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "T" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "V" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "W" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "X" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Y" Then
Ccount += 1
txtC.Text = Ccount
ElseIf letter = "Z" Then
Ccount += 1
txtC.Text = Ccount
Else
Scount += 1
txtS.Text = Scount
End If
Next i
End Sub
End Class
I have a gut instinct that it is to do with my iteration loop, either way I know im close but I am stuck in the mud on this one,
Any help would be appreciated,
Cheers,
R