Here is a simple program that I wrote using Visual Basic NET to ask the user to give a string and then our program will count the number of vowels in the given string. The code is very short and easy to understand.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
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
Public Class Form1
Const vowels = "aeiou"
Private Function Count_All_Vowels(given_string As String) As Integer
Dim i As Integer
For i = 1 To Len(given_string)
If InStr(1, vowels, Mid$(given_string, i, 1), vbTextCompare) Then
Count_All_Vowels = Count_All_Vowels + 1
End If
Next i
Return Count_All_Vowels
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label2.Text = "The Number of Vowels is " & Count_All_Vowels(UCase(TextBox1.Text)) & "."
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
End
End Sub
End Class
No comments:
Post a Comment