2017-11-25 121 views
-1

我想让我的控制台窗口在Visual Basic中打开。用我的代码,我只能要求一行,然后窗口关闭。这里是我的代码:如何让我的控制台窗口打开? VB

Module Module1 

Sub Main() 

    If (Console.ReadLine = "e") Then 
     Console.WriteLine("Test") 
    End If 

    Console.ReadKey() 

End Sub 

End Module 

所以当我运行这段代码时,我可以输入“e”按回车。单词出现“测试”,然后控制台在按下一个键后关闭。但是我想让它开放直到我写一个特殊的单词。

回答

0

这是一个愚蠢的例子:

Sub Main() 
    Dim password As String = "007" 

    Dim response As String 
    Do 
     Console.Write("Password: ") 
     response = Console.ReadLine 
     If response <> password Then 
      Console.WriteLine("Incorrect Password!") 
     End If 
    Loop While response <> password 

    Console.WriteLine("Welcome James Bond!") 
    Console.Write("Press [Enter] to proceed...") 
    Console.ReadLine() 
End Sub 
+0

谢谢您的回答。它的作品如何我想要它! – notraffic

相关问题