Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing spaces and tab characters

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
0
0
CA
Hi

How do I restrict user from typing space and tab character in textbox for inputting password.

Thanks
 
You can always use the instr() after the user submitted the password
 
Private Sub Command1_Click()
If InStr(1, Text1.Text, " ") <> 0 Then
MsgBox ("No spaces please")
End If
End Sub
 
Lot's of threads on this here's one of many thread222-608927

&quot;Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.&quot;
 
In fact, it seems to me it may be better to put checking code into the KeyPress() subroutine of the textbox into which the user is typing the password:

Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(" ") Or KeyAscii = vbTab Then
' Remove the keystroke, so the text box never sees it.
KeyAscii = 0
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top