New Employees Signup Form Excel VBA

Posted by | January 18, 2021 | Excel

 

VBA Codes Used in this Tutorial:-

Private Const mTitle As String = “Login”

This code will show the password by clicking on Checkbox

Private Sub CheckBox1_Click()

If Me.CheckBox1.Value = True Then

Me.txtPassword.PasswordChar = “”

Else

Me.txtPassword.PasswordChar = “*”

End If

End Sub

 

Private Sub cmdLogin_Click()

‘Check if both fields have a value

Dim mFields As String: mFields = “”

If txtUserName.Value = “” Then mFields = mFields & “Username” & vbNewLine

If txtPassword.Value = “” Then mFields = mFields & “Password” & vbNewLine

 

If mFields <> “” Then

MsgBox “below fields are blank.” & vbNewLine & mFields, vbCritical, mTitle

Else

Dim uSH As Worksheet: Set uSH = ThisWorkbook.Sheets(“Admin Panel”)

Dim isExit As Boolean: isExist = False

Dim wPassword As String: wPassword = “”

For a = 3 To uSH.Cells(Rows.Count, 3).End(xlUp).Row

If uSH.Range(“E” & a).Value = txtUserName.Value Then

isExist = True

wPassword = uSH.Range(“F” & a).Value

LoginName = uSH.Range(“B” & a).Value

Exit For

End If

Next a

 

If isExist = Flase Then

MsgBox “Invalid account.”, vbCritical, mTitle

txtUserName.Value = “”

txtPassword.Value = “”

txtUserName.SetFocus

 

Else

‘check if the password is correct

If txtPassword.Value <> wPassword Then

MsgBox “UserName Or Password Incorrect.”, vbCritical, mTitle

txtUserName.Value = “”

txtPassword.Value = “”

txtUserName.SetFocus

Else

‘MsgBox “Welcome Back.”, vbInformation, mTitle

MsgBox “Welcome To The Login Form Design ” & vbNewLine & _

vbNewLine & “Don’t Forget To Subscribe and Hit the Bell Icon For Latest Notifications”, vbInformation

 

Unload Me

Application.Visible = True

Unload Me

End If

End If

End If

End Sub

 

Private Sub cmdSignUp_Click()

SIGNUP.Show

End Sub

 

Private Sub txtUserName_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If StrComp(txtUserName.Value, “USERNAME”, vbTextCompare) = 0 Then

 

txtUserName.Value = “”

End If

End Sub

 

Private Sub txtPassword_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If StrComp(txtPassword.Value, “PASSWORD”, vbTextCompare) = 0 Then

 

txtPassword.Value = “”

End If

End Sub

 

Private Sub cmdReset_Click()

Unload Me

MembersLogin.Show

End Sub

 

Private Sub cmdExit_Click()

Unload Me

End Sub

 

Lets add below code to make all the UserName letter in Upper Case

Private Sub txtUserName_Change()

txtUserName = UCase(Me.txtUserName.Text)

End Sub

 

Private Sub UserForm_Initialize()

txtUserName.Value = “USERNAME”

txtPassword.Value = “PASSWORD”

End Sub

 

Workbook:

Private Sub Workbook_Activate()

Application.Visible = False

MembersLogin.Show

End Sub

 

ALL DONE LETS CLOSE AND OPEN THE FILE AGAIN…

 

430 total views, 5 today

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

WP2Social Auto Publish Powered By : XYZScripts.com