Vb.net 表达式不产生值
我有一个代码,但标题中说明了一个错误Vb.net 表达式不产生值,vb.net,Vb.net,我有一个代码,但标题中说明了一个错误 Module Module1 Dim direction As String = "" Sub Main() Console.WriteLine("As you step into the dugeon you realise you are stuck. At the end of the path it converges into 3 paths.") While direction <> "Left" And direct
Module Module1
Dim direction As String = ""
Sub Main()
Console.WriteLine("As you step into the dugeon you realise you are stuck. At the end of the path it converges into 3 paths.")
While direction <> "Left" And direction <> "right" And direction <> "Middle"
*direction = Console.WriteLine("Do you want to go left, right, or straight up?")*
End While
Console.ReadLine()
End Sub
End Module
你知道我能修好它吗?中间有星星的代码是不起作用的,所以我只需要正确的代码作为答案,然后我就可以做了。干杯。direction=Console.WriteLine。。没有意义:写!=阅读
错误是因为有一个无效的结果类型,它永远不是一个值。表示没有任何值的,不能在包含赋值的表达式中使用
代码可能应该使用WriteLine来显示文本,然后使用返回字符串的WriteLine来读取一些输入。还可以考虑对输入进行规范化,例如在读字符串上使用ToLoWi/Trimm并匹配条件检查中使用的情况。您可以编辑我的代码,然后回答吗?编辑发布的代码将导致不再准确的问题。我留下了一个解释和一些提示的答案。玩得高兴
Module Module1
Dim direction As String = ""
Sub Main()
Console.WriteLine("As you step into the dugeon you realise you are stuck. At the end of the path it converges into 3 paths.")
Do
Console.WriteLine("Do you want to go left, right, or straight up?")
direction = Console.ReadLine()
Loop While direction <> "Left" And direction <> "right" And direction <> "Middle"
End Sub
End Module