Hi there in this article I would like to share with you a sample program that I wrote using Microsoft Visual Basic 5 to ask the user to give a string or a sentence and then our program will count the number of vowels in the give string or sentence by our user. The code is very short and easy to understand. I hope you will learn from this one. Thank you.
I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Const vowels = "aeiou"
Private Function Count_All_Vowels(strText As String) As Integer
Dim i As Integer
For i = 1 To Len(strText)
If InStr(1, vowels, Mid$(strText, i, 1), vbTextCompare) Then
Count_All_Vowels = Count_All_Vowels + 1
End If
Next i
End Function
Private Sub Command1_Click()
Label2.Caption = "Total Number of Vowels is " & Count_All_Vowels(LCase(Text1.Text)) & "."
End Sub
Private Sub Command2_Click()
Label2.Caption = ""
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
No comments:
Post a Comment