Hide the password character in the textbox

Asked By 10 points N/A Posted on -

I am a newbie in learning visual basic 6.0 and I'm creating a login form for my visual basic project. I want to hide the password character on the textbox but I don't know how to do that. I want the * symbol to appear instead of my input. I need a little help with it.


Answered By 0 points N/A #103630

Hide the password character in the textbox



Hiding the password from display
Dim str As String
Private Sub Text1_KeyPress(KeyAscii As Integer)
str = str + KeyAscii
KeyAscii = Asc("*")
End Sub
make a variable global( here str).
then change the event of the text box to KeyPress event.
Key Ascii contains the ASC key of the character pressed recently.
store the value in the global variable
then change the KeyAscii to asc key value of  *.
you can now print the ‘str’ variable.
The value is thus kept hidden and secured.
Another way is by left-click the text box.
goto properties dialog box.
under Password Char, enter the character you like to show instead of the original. now run the program and see the difference.
Waiting for your feedback please.

Login/Register to Answer

Related Questions