得到错误“表达式不产生值”

时间:2018-09-25 17:51:21

标签: vb.net

对不起,如果不好,但是对VB来说真的很新,我想寻求帮助。

这是我的代码,

Module Module1

Sub Main()
    Do Until FileClose()
        Console.WriteLine("Please choose a something between * - / -+--")
        Dim test As String = Console.ReadLine

        If test = "*" Then
            Console.WriteLine("Please choose a number to multiply.")
            Dim num1 As Integer = Console.ReadLine
            Console.WriteLine("Please choose another number to multiply it with.")
            Dim num2 As Integer = Console.ReadLine
            Console.WriteLine("The answer is " & num1 * num2)
            Console.ReadKey()
        End If
        If test = "/" Then
            Console.WriteLine("Please choose a number to Divide.")
            Dim num1 As Integer = Console.ReadLine
            Console.WriteLine("Please choose another number to Divite it with.")
            Dim num2 As Integer = Console.ReadLine
            Console.WriteLine("The answer is " & num1 / num2)
            Console.ReadKey()
        End If
        If test = "+" Then
            Console.WriteLine("Please choose a number to add.")
            Dim num1 As Integer = Console.ReadLine
            Console.WriteLine("Please choose another number to add it with.")
            Dim num2 As Integer = Console.ReadLine
            Console.WriteLine("The answer is " & num1 + num2)
            Console.ReadKey()
        End If
        If test = "-" Then
            Console.WriteLine("Please choose a number to subtract.")
            Dim num1 As Integer = Console.ReadLine
            Console.WriteLine("Please choose another number to subtract it with.")
            Dim num2 As Integer = Console.ReadLine
            Console.WriteLine("The answer is " & num1 - num2)
            Console.WriteLine("If you would like to reset this calculator, please press the R button.")
            Dim test2 As String = Console.ReadLine
            If test2 = "R" Then

            End If
            Console.ReadKey()
        End If
    Loop

End Sub

End Module

对于FileClose()中的Do Until FileClose()说“表达式不产生值”

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

我猜想您要一直循环播放直到用户想要退出程序。我建议更改您的代码,使其看起来如下所示

Dim test As String
Do
    Console.WriteLine("Please choose a something between * - / -+-- or type ""exit"" to end the program")
    test = Console.ReadLine
    'rest of your code
Loop Until test = "exit"