sql-servervb.netoop

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

Solution

  • enter image description here

    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