DEV Community

Cover image for VB .Net: PasswordFromKeys
vblover programmer
vblover programmer

Posted on

VB .Net: PasswordFromKeys

Method:

    Function PasswordFromKeys() As String
        Dim Key As ConsoleKeyInfo
        Dim Expr As String = ""
        Do
            Key = Console.ReadKey(True)
            Select Case Key.Key
                Case ConsoleKey.Enter
                    Exit Do
                Case ConsoleKey.Escape
                    Return ""
                Case ConsoleKey.Backspace
                    If Expr.Length = 0 Then Continue Do
                    Expr = Expr.Remove(Expr.Length - 1, 1)
                    Console.Write("{0} {0}", Key.KeyChar)
                Case ConsoleKey.NumPad0 To ConsoleKey.NumPad9,
                     ConsoleKey.D0 To ConsoleKey.D9,
                     ConsoleKey.A To ConsoleKey.Z
                    Expr += Key.KeyChar
                    Console.Write("*")
                Case Else
                    Continue Do
            End Select
        Loop
        Return Expr
    End Function
Enter fullscreen mode Exit fullscreen mode

Using:

Console.ForegroundColor = ConsoleColor.White
Console.Write("{0} Type Password: ", vbTab)
Console.ForegroundColor = ConsoleColor.Green
Dim Password As String = PasswordFromKeys()
Console.WriteLine()
Console.ForegroundColor = ConsoleColor.White
Console.Write("{0} Your Password is: ", vbTab)
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("{0}", Password)
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more