这真的让我很困惑。我正在尝试做一个 Visual Basic 控制台应用程序,如果用户输入“A”或“a”,那么程序应该执行“x”,但这不起作用。我得到的错误是:
从字符串“a”到类型“Boolean”的转换无效。
这是我的代码:
模块模块1
Sub Main()
Dim Selection As String
Console.WriteLine("Please select your function:")
Console.WriteLine("* To convert binary to decimal, press A,")
Console.WriteLine("* Or to convert decimal to binary, press B")
Selection = Console.ReadLine
If Selection = "A" Or "a" Then
Console.WriteLine("This will be A")
ElseIf Selection = "B" Or "b" Then
Console.WriteLine("This will be B")
ElseIf Selection = Not "A" Or "a" Or "B" Or "b" Then
Console.WriteLine("Please try again")
Do Until Selection = "A" Or "a" Or "B" Or "b"
Loop
End If
End Sub
应该在这段代码中正确使用 Or 以使其正常运行?
谢谢,
杰克