|
-
Apr 25th, 2008, 10:07 AM
#1
Thread Starter
Frenzied Member
cannot input text in the textbox
I cannot insert any input into my textbox. Every time I insert one text or number from keyboard, I got this messagebox MsgBox "Please input valid password", vbCritical, "Warning". So How I can input full password into my textbox?
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii ' This case statment check that no text can be entered.
Case vbKeyDelete ' Delete Key
Case vbKeyBack 'Baskspace key
Case vbKeyReturn
Case Else
Dim usrnm As String
usrnm = TextBox1.Text
adoRS.Close
adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
If adoRS.Fields("Password").Value = TextBox1.Text And adoRS.Fields("username").Value = "Pengurus" Then
pass = True
'if password valid, success
Unload Me
frmMain.Show
Else
'If password invalid
intCounter = intCounter + 1
If intCounter = 4 Then
MsgBox "You have insert invalid password more then 3", vbCritical, "Warning"
intCounter = 0
Unload Me
Application.Shutdown
Else
MsgBox "Please input valid password", vbCritical, "Warning"
TextBox1.SetFocus
TextBox1.Text = ""
End If
End If
-
Apr 25th, 2008, 10:24 AM
#2
Re: cannot input text in the textbox
That's because you are telling it to check it everytime you enter a character (equivalent to pressing a key) in the textbox...
Private Sub Text1_KeyPress(KeyAscii As Integer) <======
you need to use a different approach. Since you are already comparing the password here
If adoRS.Fields("Password").Value = TextBox1.Text And ......
Then does it really matter to restrict the input in the textbox?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 25th, 2008, 10:28 AM
#3
Re: cannot input text in the textbox
Try something like
Code:
Private Sub Text1_LostFocus()
Dim usrnm As String
usrnm = TextBox1.Text
adoRS.Close
adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
If adoRS.Fields("Password").Value = TextBox1.Text And adoRS.Fields("username").Value = "Pengurus" Then
pass = True
'if password valid, success
Unload Me
frmMain.Show
Else
'If password invalid
intCounter = intCounter + 1
If intCounter = 4 Then
MsgBox "You have insert invalid password more then 3", vbCritical, "Warning"
intCounter = 0
Unload Me
Application.Shutdown
Else
MsgBox "Please input valid password", vbCritical, "Warning"
TextBox1.SetFocus
TextBox1.Text = ""
End If
End If
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|