简体   繁体   中英

how do i create a coding to hide login password in visual basic 2012 (OOP method)

i'm working on coding of login form program using visual studio 2012 and SQL server 2012.

the function i want is this: when i type the password during login the password will show "*" instead of the password.

what is the coding to do that?

my login form:

Public Class Form2

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        BackColor = Color.LightGray
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ClassSiswa.namadatabase = "KPIRWAN"
        Dim caridata As SqlClient.SqlDataReader
        caridata = ClassSiswa.CariDataPengguna(ClassSiswa.opencon, TextBox1.Text, TextBox2.Text)
        If Not caridata.Read Then
            MsgBox("Nama dan Sandi Tidak Terdaftar")
        Else
            Me.Hide()
            Form1.Show()
        End If
        ClassSiswa.closecon()
    End Sub

End Class

在此处输入图片说明

See this photo?? after you click your textbox once, go through the Properties box and look for the PasswordChar and type the asterisk(*) symbol. And when you run the program and type the password, providing that the textbox of your password is the same textbox where you typed the asterisk symbol under its properties, it will show asterisk instead of the words inputted.

Or you can simply type this under your form_load

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    TextBox1.PasswordChar = "*"
End Sub

So you want showing the text on your textbox to somethink like "****", right?
Assumption your textbox2 is textbox for input password...
just put this code to your load Event

TextBox21.UseSystemPasswordChar = True

or you can right click on textbox2 -> click properties -> then in properties windows, set UseSystemPasswordChar to True...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM