1. Character Count user interface:
2. The Code....
Public Class frmCharacterCount
Private Sub btnClickHereToCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClickHereToCount.Click
Dim length, x, count As Integer
Dim letter As String
length = Microsoft.VisualBasic.Len(txtPhrase.Text)
For x = 1 To length
letter = Microsoft.VisualBasic.Mid(txtPhrase.Text, x, 1)
If Microsoft.VisualBasic.StrComp(letter, txtcharacter.Text, CompareMethod.Text) = 0 Then
count = count + 1
End If
Next
lblOutput.Text = "There are " & count & " " & txtcharacter.Text & " in the Phrase."
End Sub
Private Sub exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exit.Click
Me.Close()
End Sub
End Class
3. Save and RUN the program...
No comments:
Post a Comment