嗨我需要將WordCount和CountVowel過程更改爲函數,並創建一個函數來計算字符串中輔音的數量。CountWord和CountVowel在VB.NET中進入函數
我已經完成了這兩個程序,但我不知道如何做最後一部分。我對編程相當陌生。下面
我當前的代碼給出:
Sub Main()
Dim Sentence As String
Console.WriteLine("Sentence Analysis" + vbNewLine + "")
Console.WriteLine("Enter a sentence, then press 'Enter'" + vbNewLine + "")
Sentence = Console.ReadLine()
Console.WriteLine("")
Call WordCount(Sentence)
Call VowelCount(Sentence)
Console.ReadLine()
End Sub
Sub WordCount(ByVal UserInput As String)
Dim Space As String() = UserInput.Split(" ")
Console.WriteLine("There are {0} words", Space.Length)
End Sub
Sub VowelCount(ByVal UserInput As String)
Dim i As Integer
Dim VowelNumber As Integer
Dim Vowels As String = "aeiou"
For i = 1 To Len(UserInput)
If InStr(Vowels, Mid(UserInput, i, 1)) Then
VowelNumber = VowelNumber + 1
End If
Next
Console.WriteLine("There are {0} vowels", VowelNumber)
End Sub
感謝您的時間
當然,但對於剛剛嘗試學習編程基礎知識的人來說,這似乎是一個奇怪的建議。 –