snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Dim mFields As String: mFields = ""
If Usernames.Value = "" Then mFields = mFields & "Username" & vbNewLine
If passwords.Value = "" Then mFields = mFields & "password" & vbNewLine
If mFields <> "" Then
MsgBox "กรุณากรอกข้อมูลเข้าสู่ระบบ" & vbNewLine & mFields, vbCritical, mTitel
Else
Dim uSH As Worksheet: Set uSH = ThisWorkbook.Sheets("Login")
Dim isExist As Boolean: isExist = False
Dim wpassword As String: wpassword = ""
For c = 2 To uSH.Cells(Rows.Count, 2).End(xlUp).Row
If uSH.Range("A" & c).Value = Usernames.Value Then
isExist = True
wpassword = uSH.Range("B" & c).Value
Loginnames = uSH.Range("C" & c).Value
Exit For
End If
Next c
If isExist = False Then
MsgBox "คุณกรอก Username ผิด", vbCritical, mTitel
Usernames.Value = ""
passwords.Value = ""
Usernames.SetFocus
Else
If passwords.Value <> wpassword Then
MsgBox "คุณกรอก password ผิด", vbCritical, mTitel
Usernames.Value = ""
passwords.Value = ""
Usernames.SetFocus
Else
MsgBox "Welcome", vbInformation, mTitel
Unload Me
ผู้ใช้งาน.Show
End If
End If
End If
You do not have the required permissions to view the files attached to this post.
Dim mFields As String: mFields = ""
If Usernames.Value = "" Then mFields = mFields & "Username" & vbNewLine
If passwords.Value = "" Then mFields = mFields & "password" & vbNewLine
If mFields <> "" Then
MsgBox "กรุณากรอกข้อมูลเข้าสู่ระบบ" & vbNewLine & mFields, vbCritical, mTitel
Else
Dim uSH As Worksheet: Set uSH = ThisWorkbook.Sheets("Login")
Dim isExist As Boolean: isExist = False
Dim wpassword As String: wpassword = ""
For c = 2 To uSH.Cells(Rows.Count, 2).End(xlUp).Row
If uSH.Range("A" & c).Value = Usernames.Value Then
isExist = True
wpassword = uSH.Range("B" & c).Value
Loginnames = uSH.Range("C" & c).Value
Exit For
End If
Next c
If isExist = False Then
MsgBox "คุณกรอก Username ผิด", vbCritical, mTitel
Usernames.Value = ""
passwords.Value = ""
Usernames.SetFocus
Else
If passwords.Value <> wpassword Then
MsgBox "คุณกรอก password ผิด", vbCritical, mTitel
Usernames.Value = ""
passwords.Value = ""
Usernames.SetFocus
Else
MsgBox "Welcome", vbInformation, mTitel
Dim lRow As Long: lRow = 0
lRow = uSH.Cells(Rows.Count, 2).End(xlUp).Row + 1
uSH.Range("G" & c).Value2 = Date
uSH.Range("H" & c).Value2 = Time
Unload Me
ผู้ใช้งาน.Show
End If
End If
End If
You do not have the required permissions to view the files attached to this post.