Computers & Internet Logo

Related Topics:

jhem lenard Posted on Feb 21, 2008
Answered by a Fixya Expert

Trustworthy Expert Solutions

At Fixya.com, our trusted experts are meticulously vetted and possess extensive experience in their respective fields. Backed by a community of knowledgeable professionals, our platform ensures that the solutions provided are thoroughly researched and validated.

View Our Top Experts

Help me visual basic code in determining the number of vowel and the number of the consonant if i enter a word

1 Answer

Anonymous

Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that got 5 achievements.

Governor:

An expert whose answer got voted for 20 times.

Scholar:

An expert who has written 20 answers of more than 400 characters.

  • Expert 148 Answers
  • Posted on Feb 21, 2008
Anonymous
Expert
Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that got 5 achievements.

Governor:

An expert whose answer got voted for 20 times.

Scholar:

An expert who has written 20 answers of more than 400 characters.

Joined: Feb 19, 2008
Answers
148
Questions
0
Helped
80018
Points
321

Sub CountCharacters(Text As String)
Dim iVowel As Integer
Dim iCons As Integer
Dim iNum As Integer
Dim iSpace As Integer
Dim iOther As Integer

Dim cnt As Integer
Dim sChar As String

For cnt = 1 To Len(Text)
sChar = LCase(Mid(Text, cnt, 1))

Select Case sChar
Case "a", "e", "i", "o", "u" ' And sometimes "y"?
' Vowel
iVowel = iVowel + 1
Case "a" To "z"
' Includes the first case, but VB matches the first case and stops
iCons = iCons + 1
Case "0" To "9"
' Numbers
iNum = iNum + 1
Case " ", vbTab, vbLf
' Space characters
' Not including vbCr as this will likely be dealing with Windows text
' and I only want to match one character for a newline
iSpace = iSpace + 1
Case Else
If sChar <> vbCr Then iOther = iOther + 1
End Select
Next cnt

Debug.Print "Text: " & Text
Debug.Print "Vowels: " & CStr(iVowel)
Debug.Print "Consonants: " & CStr(iCons)
Debug.Print "Numbers: " & CStr(iNum)
Debug.Print "Space characters: " & CStr(iSpace)
Debug.Print "Other: " & CStr(iOther)
End Sub

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

Is wise a consonant

no it is no a consonant is a speech sound that is not a vowel
it also refers to letters of the alphabet that represents those sounds
Z, B, T, G, and H are all consonants
the A, E I,O U of the alphabet are vowels and the rest are consonants
go google and type in www.vocabulary.com/dictionary/consonant to get the idea
0helpful
1answer

How do I break the work "exhibition" into syllables?

Have your program split the word into groups of vowels and consonants ie 'exh', 'ib', 'it', 'ion'. For example if the word starts with a vowel, in this case 'e', continue to group it until it reaches the first vowel (i in the 2nd group) after the group of consonants (x and h in the first group), and repeat.
0helpful
1answer

How do I divide the word meat into syllables?

Given your list of words, It appears to me that what makes up a syllable is the vowels in the word.. each time 1 or more vowels are separated by 1 or more consonants/symbols, a syllable is born.
so, have an array of characters containing vowels.
now iterate through the given word and create a new syllable(String) by adding the characters you are inspecting until you find a vowel.. now continue to add the vowels you find until you find a consonant/symbol.. that's where your new syllable ends (you can add it to a List if you want or just output it to the command line) ..and if you haven't gone through the entire word yet, create a new syllable(String) and repeat the process.

Good luck
0helpful
1answer

How to play scrabble dash?

Each player has a hand of 7 letter cards - initially 5 consonants and 2 vowels, but as the game progresses players can refill their hands freely from the separate vowel and consonant decks to vary the mix.
On each turn, the top Dash card is turned face up, revealing the goal for that turn. Players then race to play a word from their hands to fulfil the Dash card, or skip the turn to discard cards and draw new ones.
The Dash cards include criteria such as number of letters (ranging from 2 to 4), specific parts of speech (verb/proper noun), or specifying that the word has to start, end with, or contain a particular letter, drawn at random from either the vowel or consonant deck (players do not need to play their own copy of this letter from their hand).
The first player to lay down a valid word claims the Dash card, and the first player to collect 5 Dash cards wins the game.
Jun 21, 2014 • Games
0helpful
1answer

Write a program for analyzing which of severaol diff.vowels ,cont

#
# Since no language was specifiec, here's a solution in the
# gawk dialect of awk.
#
# Familiarity with awk is assumed, so only minimal comments
# are present. I have a version with more comments...
#


BEGIN {
IGNORECASE = 1
}

{ r0 = $0 } # Copy the input record into the variable r0, for efficiency

wc += gsub(/[[:blank:]]+/, "", r0) {} # Destructively count all the white spaces in r0

vc += gsub(/[AEIOU]/, "", r0) {} # Destructively count all the vowels in r0

cc += gsub(/[BCDFGHJKLMNPQRSTVWXYZ]/, "", r0) {} # Destructively count all the consonants in r0

END {
printf("%d vowel%s\n", vc, (vc != 1) ? "s" : "")
printf("%d consonant%s\n", cc, (cc != 1) ? "s" : "")
printf("%d white space%s\n", wc, (wc != 1) ? "s" : "")
}

1helpful
1answer

Program

I wrote this as a vbscript. It's Visual Basic code in windows script. If you have XP, just copy the text into notepad and save it as "vowel.vbs". Now double click the newly created script file.

' vowel.vbs
'
' This VBScript is used to count the vowels and consonants in a string.
' Designed and Tested on Windows XP Pro SP2
'
' Version 1.0.0 - 02.20.2008
'
' This code may be freely distributed or modified.
' -----------------------------------------------------------------'

Option Explicit
Dim str
Dim vowels
Dim consonants
Dim i

vowels = 0
consonants = 0
str = "hello"

for i = 1 to len(str)
select case mid(str,i,1)
case "a"
vowels = vowels + 1
case "e"
vowels = vowels + 1
case "i"
vowels = vowels + 1
case "o"
vowels = vowels + 1
case "u"
vowels = vowels + 1
case else
consonants = consonants + 1
end select
next

msgbox "Vowels = " & vowels
msgbox "Consonants = " & consonants
'End of script.
0helpful
1answer

Help

i did not solve my problem yesterday.
that's why i need your help..
please help me to solve my problem that i posted yesterday.i need your help.
thank you very much.
0helpful
2answers

Help me

this the code for your problem. by the way this for vb6.0

Sub CountCharacters(Text As String)
Dim iVowel As Integer
Dim iCons As Integer
Dim iNum As Integer
Dim iSpace As Integer
Dim iOther As Integer

Dim cnt As Integer
Dim sChar As String

For cnt = 1 To Len(Text)
sChar = LCase(Mid(Text, cnt, 1))

Select Case sChar
Case "a", "e", "i", "o", "u" ' And sometimes "y"?
' Vowel
iVowel = iVowel + 1
Case "a" To "z"
' Includes the first case, but VB matches the first case and stops
iCons = iCons + 1
Case "0" To "9"
' Numbers
iNum = iNum + 1
Case " ", vbTab, vbLf
' Space characters
' Not including vbCr as this will likely be dealing with Windows text
' and I only want to match one character for a newline
iSpace = iSpace + 1
Case Else
If sChar <> vbCr Then iOther = iOther + 1
End Select
Next cnt

Debug.Print "Text: " & Text
Debug.Print "Vowels: " & CStr(iVowel)
Debug.Print "Consonants: " & CStr(iCons)
Debug.Print "Numbers: " & CStr(iNum)
Debug.Print "Space characters: " & CStr(iSpace)
Debug.Print "Other: " & CStr(iOther)
End Sub
0helpful
1answer

Hi........

I wrote this as a vbscript. It's Visual Basic code in windows script. If you have XP, just copy the text into notepad and save it as "vowel.vbs". Now double click the newly created script file.

' vowel.vbs
'
' This VBScript is used to count the vowels and consonants in a string.
' Designed and Tested on Windows XP Pro SP2
'
' Version 1.0.0 - 02.20.2008
'
' This code may be freely distributed or modified.
' -----------------------------------------------------------------'

Option Explicit
Dim str
Dim vowels
Dim consonants
Dim i

vowels = 0
consonants = 0
str = "hello"

for i = 1 to len(str)
select case mid(str,i,1)
case "a"
vowels = vowels + 1
case "e"
vowels = vowels + 1
case "i"
vowels = vowels + 1
case "o"
vowels = vowels + 1
case "u"
vowels = vowels + 1
case else
consonants = consonants + 1
end select
next

msgbox "Vowels = " & vowels
msgbox "Consonants = " & consonants
'End of script.
0helpful
2answers

Visual basic code

'Text1 is a textbox or a string you can use

Private Sub Command1_Click()
Dim a
Dim vow, con As Integer
vow = 0
con = 0
For i = 1 To Len(Text1)
a = Mid(Text1, i, 1)
If (a = "a" Or a = "e" Or a = "i" Or a = "o" Or a = "u") Then
vow = vow + 1
Else
con = con + 1
End If
Next
MsgBox "Vowels: " & vow & vbNewLine & "Consonants : " & con

End Sub
Not finding what you are looking for?

203 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

Brad Brown

Level 3 Expert

19187 Answers

Cindy Wells

Level 3 Expert

6688 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...