“””””””””
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Const GWL_STYLE As Long = (-16)
“””””””””””””””””“”””””””””””””””””””””
Private Sub CommandButtonStm_Cancel_Click()
On Error Resume Next
ActiveWorkbook.Save
ActiveWorkbook.Close
Unload Me
End Sub
“””””””””””””””””””””“””””””””””””””””””
Private Sub CommandButtonStm_Login_Click()
If Me.TextBoxStm_User_Name.Value = "Admin" And Me.TextBoxStm_Password.Value = "321" Then
MsgBox "WELCOME"
UserFormMenu.Show
Unload Me
Else
MsgBox "Please Try Again"
Me.TextBoxStm_User_Name.Value = "" Me.TextBoxStm_Password.Value = ""
End If
End Sub
“”””””””””””””””””””””””””””””””””””””””“””””””””””””””””””””””””””””””””””
Private Sub UserForm_Initialize()
On Error Resume Next
Dim frm As Long
Dim wHandle As Long
wHandle = FindWindow(vbNullString, Me.Caption)
frm = GetWindowLong(wHandle, GWL_STYLE)
SetWindowLong wHandle, -16, 0
DrawMenuBar wHandle
End Sub
“”””””””””””””””””””””””””””””””””””””
Full code PDF download
