Q. Write a software using Visual Basic 2010 for login purpose with two input boxes for username and
password and appropriate buttons. When the user click login button, the software will check the
password with the password set by you and then display message box accordingly.
Source Code:
Public Class Form1
Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
If UserNameTextBox.Text = "Tommy" And PasswordTextBox.Text = "Tommy" Then
MessageBox.Show("You Are Login", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Wrong User Name and Password", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
PasswordTextBox.UseSystemPasswordChar = False
ElseIf CheckBox1.Checked = False Then
PasswordTextBox.UseSystemPasswordChar = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
password and appropriate buttons. When the user click login button, the software will check the
password with the password set by you and then display message box accordingly.
Source Code:
Public Class Form1
Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
If UserNameTextBox.Text = "Tommy" And PasswordTextBox.Text = "Tommy" Then
MessageBox.Show("You Are Login", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Wrong User Name and Password", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
PasswordTextBox.UseSystemPasswordChar = False
ElseIf CheckBox1.Checked = False Then
PasswordTextBox.UseSystemPasswordChar = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Comments
Post a Comment