【发布时间】:2017-10-25 11:31:25
【问题描述】:
我正在用 VB 制作石头、纸、剪刀游戏。我正在寻找一种方法来完成以下工作:
Select Case userInput
Case = "rock" And computerOutput = "scissors"
Console.WriteLine("You win! You picked " & userInput & ", and the computer picked " & computerOutput & "! Rock beats Scissors, hit enter to continue...")
Console.ReadLine()
userScore = userScore + 1
userInput 和 computerInput 总是石头、纸或剪刀。
但是当我尝试它时,我收到以下错误:
System.InvalidCastException: 'Conversion from string "rock" to type 'Boolean' is not valid.'
我是 VB 新手,所以不太清楚该怎么做。
【问题讨论】:
-
我们需要查看更多代码才能理解您的问题。
-
这不是编写 Select Case 语句的方法。你应该看Excel VBA Introduction Part 14 - Select Case Statements
-
我猜你用的是vb.net?请在
Case = "rock" And computerOutput = "scissors"行之前和之后再提供几行代码 -
我将编辑帖子以添加它
标签: .net vb.net visual-studio