How to Create This Powerful Login Form in Excel using Excel VBA.

Опубликовано: 06 Октябрь 2024
на канале: ST: Excel Guru
4,296
69

Copy the Code below
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Me.notify1.Visible = False
Me.notify2.Visible = False
Me.notify3.Visible = False
Me.TextBox2.PasswordChar = "*"
End Sub

Private Sub Label1_Click()

''''Validation
If Me.TextBox1.Value = "" And Me.TextBox2.Value = "" Then
Me.notify1.Visible = True
Exit Sub
End If

If Me.TextBox2.Value = "" Then
Me.notify2.Visible = True
Exit Sub
End If

If Me.TextBox1.Value = "" Then
Me.notify3.Visible = True
Exit Sub
End If

''''''''''''Login Details
If Me.TextBox1.Value = "Admin" And Me.TextBox2.Value = "admin123" Then
MsgBox "You have successfully unlock the SBA management system. Welcome Admin", vbInformation
Unload Me
Application.Visible = True
Else
MsgBox "Please enter correct username & password"
TextBox1 = ""
TextBox2 = ""
End If
End Sub

Private Sub Label2_Click()

ThisWorkbook.SAVE
Unload Me
Application.Quit

End Sub

Private Sub Label3_Click()

Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
End Sub


Private Sub Label4_Click()
Me.TextBox2.PasswordChar = ""
End Sub

Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.Visible = False
Application.Visible = False
LOGIN.Show
Worksheets("Home").Activate
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False
Application.ScreenUpdating = True
End Sub