-
count the number of vowels in a string
hello.. how am i to code a program tht will accept a line of string from a user and count the number of vowels in tht particular string? plz help
-
Here is an example of what you could do, though I'm sure some of the professionals on this forum could do something more elegant:
Put a command button and a textbox on a form and place this code in the click event for the command button.
------------------------------------------------------------------------
HTML Code:
Dim intCounter As Integer
Dim intVowels As Integer
Dim strLetter As String
' count vowels in a string
' search for a
For intCounter = 1 To Len(Text1.Text)
strLetter = LCase(Mid(Text1.Text, intCounter, 1))
Select Case strLetter
Case Is = "a"
intVowels = intVowels + 1
Case Is = "e"
intVowels = intVowels + 1
Case Is = "i"
intVowels = intVowels + 1
Case Is = "o"
intVowels = intVowels + 1
Case Is = "u"
intVowels = intVowels + 1
Case Else:
' do nothing
End Select
Next intCounter
MsgBox "Number of vowels: " & intVowels
-
just a small change in Lithic code:
select case strLetter
case "a","b","c","d","e"
intvowels=intvowels+1
end select
Marco
-
Thanks for that Marco, this site is great for learning and refining techniques.
Cheers,
Lithic.
-
thanks
thank you so much guys for helping me out.. appreciate it =)
-
ummmm.............marco! She wanted the number of VOWELS!
b,c,and d aren't vowels! :-Þ
select case strLetter
case "a","e","i","o","u"
intvowels=intvowels+1
end select
L
A balanced diet is a cookie in each hand.
-
ops... too much time using programming languages. I need a break, I am alraedy making too many spelling mistekes.
Thanks Laurel.
Well, you told me I WAS funny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks