Imports System.Data Imports System.Data.SqlClient Public Class loginForm Public cnstr As String Public username As String Public userType As String Public userSRList As List(Of String) Dim connection As New Connection Dim conn As SqlConnection Private Function validateUser() As Boolean Dim currentUser As New User(txtUsername.Text) If StrComp(RTrim(currentUser.password), currentUser.EncryptString(txtPassword.Text), CompareMethod.Text) = 0 Then username = currentUser.username userType = currentUser.usertype Return True Else Return False End If End Function Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click If validateUser() = True Then Me.Hide() mainForm.Show() Else MessageBox.Show("Either user does not exists or password is incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click Me.Close() End Sub Private Sub txtPassword_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPassword.KeyUp If e.KeyCode = Keys.Enter Then If validateUser() = True Then Me.Hide() mainForm.Show() Else MessageBox.Show("Either user does not exists or password is incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If btn_ok.Focus() End If End Sub End Class