我最近发现很难识别我工作中的元音,我的老师也问我这样做,有没有人有办法做到这一点?...目前我的代码是。
Dim mystring As String
Dim isitavowel As Boolean
Dim VOWELCOUNT As Integer
Sub Main()
Console.WriteLine("Enter the text of your choice here")
mystring = Console.ReadLine
VOWELCOUNT = 0
For i = 1 To mystring.Length
isitavowel = False
If mystring(i - 1) = "a" Or mystring(i - 1) = "A" Then isitavowel = True
If mystring(i - 1) = "e" Or mystring(i - 1) = "E" Then isitavowel = True
If mystring(i - 1) = "i" Or mystring(i - 1) = "I" Then isitavowel = True
If mystring(i - 1) = "o" Or mystring(i - 1) = "O" Then isitavowel = True
If mystring(i - 1) = "u" Or mystring(i - 1) = "U" Then isitavowel = True
If isitavowel = True Then
VOWELCOUNT = VOWELCOUNT + 1
End If
Next
Console.WriteLine("That had " & VOWELCOUNT & " vowel's in it")
Console.ReadLine()
问题是有时它会出现错误。请帮忙!