我正在尝试使用 Visual Basic 中的 for 循环将字符串变量与字符串数组的元素进行比较。我按顺序将用户输入的字符串变量与具有小写字母的数组进行比较。我有一些逻辑错误,因为我的“计数”变量出于某种原因总是在 25 上,因此它总是说“抱歉,再试一次”,除非用户键入 Z。请帮助!
Dim lower() As String = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
For count As Integer = 0 To 25
input = txtInput.Text
input = input.ToLower
If input.Equals(lower(count)) Then
txtResult.Text = "Correct"
Else
txtResult.Text = "Sorry, Try again"
End If
Next