Qbasicnews.com

Full Version: passwords
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
how would i go about making it so when you type something in, the letters are replaced by a *?

:bounce:
Use INKEY$.
Code:
CLS
b$ = ""
y = 1

LOCATE y
PRINT "_"

DO
   a$ = ""
   WHILE a$ = ""
      a$ = INKEY$
   WEND

   SELECT CASE a$
      CASE CHR$(13)
         EXIT DO
      CASE CHR$(27)
         b$ = ""
      CASE CHR$(8)
         IF b$ = "" THEN
            BEEP
         ELSE
            b$ = MID$(b$, 1, LEN(b$) - 1)
         END IF
      CASE ELSE
         b$ = b$ + a$
   END SELECT

   LOCATE y
   PRINT STRING$(LEN(b$), "*"); "_"; SPACE$(78 - LEN(b$))
LOOP
This problem has been done so many times now... I even held a challenge here to simulate a password thing (which I think Meg won with a "matrix" password thing). Check the challenge thread for all the problems you could have with password things, and the solutions people came up with Smile
flex: Your code only prints the letter typed to make it print '*' you need this
Code:
CLS
b$ = ""
y = 1
DO
    a$ = ""
    WHILE a$ = ""
        a$ = INKEY$
    WEND
    SELECT CASE a$
       CASE CHR$(13)
            EXIT DO
       CASE CHR$(27)
            b$ = ""
        CASE CHR$(8)
            IF b$ = "" THEN
                BEEP
            ELSE
                b$ = MID$(b$, 1, LEN(b$) - 1)
            END IF
        CASE ELSE
            b$ = b$ + "*"
            c$ = c$ + a$
    END SELECT

    LOCATE y: PRINT b$; SPACE$(80 - LEN(b$))
LOOP
PRINT c$
i edited my code just to add a cursor marker... but come on, if you can't see why my code is fine... then you need some professional help Smile




[Flexibal>
Quote:i edited my code just to add a cursor marker... but come on, if you can't see why my code is fine... then you need some professional help Smile




[Flexibal>
oh. nvm. yours is still better
*flattered*
:bounce:





[Flexibal>
thx
Here's another one: (submitted to Q-Tech by Zack)

Code:
CLS
PRINT "Enter Password: ";
row = 1
col = 17
LOCATE row, col
DO
press$ = INKEY$
IF press$ <> "" AND press$ <> CHR$(8) THEN
IF press$ = CHR$(13) THEN EXIT DO
LOCATE row, col
PRINT "*";
pswd$ = pswd$ + press$
col = col + 1
LOCATE row, col
END IF
IF press$ = CHR$(8) AND col - 1 >= 17 THEN
a$ = LEFT$(pswd$, LEN(pswd$) - 1)
col = col - 1
LOCATE row, col: PRINT " ";
pswd$ = a$
END IF
LOOP
Pages: 1 2