控制台应用程序登录(类似于MySql)

时间:2018-02-13 15:33:39

标签: vb.net login console-application

我做了一个简单的登录,我想做一个类似于MySql的登录,但我不知道为什么不能这样做,所以如果有人知道怎么做,那么我可以改变用户名和密码而不从应用程序更改它。 只需一个真正的登录,如果有人知道如何做到这一点

现在我正在使用此代码:

    Dim Username As String = Nothing
    Dim Password As String = Nothing

    Console.WriteLine("Username: ")
    Console.CursorTop = Console.CursorTop - 1
    Console.SetCursorPosition(Len("Username; " & Username), Console.CursorTop)
    Username = Console.ReadLine
    Console.WriteLine("Password: ")
    Console.CursorTop = Console.CursorTop - 1
    Console.SetCursorPosition(Len("Password; " & Password), Console.CursorTop)
    Password = Console.ReadLine

    If Username = "Example" And Password = "ExamplePassword" Then
    ....
    End if
  

但是我想要一个类似于MySql Method的登录...

1 个答案:

答案 0 :(得分:0)

使用Write而不是WriteLine,而不是更改光标,所以它保持在您想要的行上:

   Console.Write("Username: ")
   Dim userName As String = Console.ReadLine()