Page 1 of 1

user login ช่วยดูโค๊ดให้หน่อยครับ

Posted: Thu Dec 31, 2020 1:11 pm
by thakorn.tum
ผมเขียนโค๊ดดังนี้ เข้าได้แต่มันไปเปลี่ยนค่าของ Admin จะทำอย่างไรให้เข้าไปเช็คว่าตรงกัน username และ password แล้วถ้าตรงกันให้เข้าได้ครับ

Sub CheckUser()


Dim SheetNm As String

chkUserX = Sheet15.Range("A12").Value
chkPassX = Sheet15.Range("B12").Value



If UserX = "" And PassX = "" Then
MsgBox ("Invalid username or password!"), vbOKOnly
LoginForm.Username.Value = ""
LoginForm.Password.Value = ""
LoginForm.Username.SetFocus
ElseIf UserX = Empty Then 'Incorrect Username
MsgBox "Please enter a correct username"
Exit Sub

ElseIf PassX = "" Then 'Incorrect password
MsgBox "Pleae enter a correct password"
Exit Sub

ElseIf UserX <> "" And PassX <> "" Then




If UserX = chkUserX And PassX = chkPassX Then

LoginForm.Hide
MsgBox "Hollo welcome to Ãкº Admin"
Sheet15.Activate
Else
MsgBox "¡ÃÍ¡¼ÙéãªéáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ"
End If


End If




End Sub

Re: user login ช่วยดูโค๊ดให้หน่อยครับ

Posted: Thu Dec 31, 2020 5:27 pm
by puriwutpokin
thakorn.tum wrote: Thu Dec 31, 2020 1:11 pm ผมเขียนโค๊ดดังนี้ เข้าได้แต่มันไปเปลี่ยนค่าของ Admin จะทำอย่างไรให้เข้าไปเช็คว่าตรงกัน username และ password แล้วถ้าตรงกันให้เข้าได้ครับ

Sub CheckUser()


Dim SheetNm As String

chkUserX = Sheet15.Range("A12").Value
chkPassX = Sheet15.Range("B12").Value



If UserX = "" And PassX = "" Then
MsgBox ("Invalid username or password!"), vbOKOnly
LoginForm.Username.Value = ""
LoginForm.Password.Value = ""
LoginForm.Username.SetFocus
ElseIf UserX = Empty Then 'Incorrect Username
MsgBox "Please enter a correct username"
Exit Sub

ElseIf PassX = "" Then 'Incorrect password
MsgBox "Pleae enter a correct password"
Exit Sub

ElseIf UserX <> "" And PassX <> "" Then




If UserX = chkUserX And PassX = chkPassX Then

LoginForm.Hide
MsgBox "Hollo welcome to Ãкº Admin"
Sheet15.Activate
Else
MsgBox "¡ÃÍ¡¼ÙéãªéáÅÐÃËÑʼèÒ¹äÁè¶Ù¡µéͧ"
End If


End If




End Sub
ยกเลิกในส่วนนี้ดูครับ

Code: Select all

'Private Sub Username_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Sheet15.Range("B11").Value = Username.Value
'End Sub
'Private Sub Password_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Sheet15.Range("B12").Value = Password.Value
'End Sub

Re: user login ช่วยดูโค๊ดให้หน่อยครับ

Posted: Fri Jan 01, 2021 7:40 am
by thakorn.tum
ขอบคุณครับได้ แล้วครับ