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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I make sure a use does not input a " " in a field.

Status
Not open for further replies.

chiefvj

Technical User
Feb 4, 2005
73
US
I'm not refering to a null. I want to trap ie. a space that a user accidentally enters into a field.
thx in advance.
 
A space alone ? A space inside a text ? A leading space ? A trailing space ?
Bottom line: explain CLEARLY what you want to do ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
If the user hits the space-bar I want this code to run.
The code should trap for the space-bar.
thx


Private Sub combo_sport_KeyPress(KeyAscii As Integer)

Dim thekey As String
thekey = KeyAscii

If thekey = "324" Then
MsgBox ("We are in a space " & combo_sport)
Else
MsgBox ("keyascii= " & KeyAscii & vbYesNo)
End If

End Sub
 
The code should trap for the space-bar
Like this ?
Code:
Private Sub combo_sport_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
   MsgBox "We are in a space  " & combo_sport
Else
   MsgBox "keyascii=" & KeyAscii
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Wow! that was it...could you explain what I was doing wrong?.
 
could you explain what I was doing wrong
32 is not the same than "324"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I ran a msgbox and the indication was that depressing the space bar generated an ascci code number "324".
thx
 
I tested with this bit of code
Code:
Private Sub txtText_KeyPress(KeyAscii As Integer)
    lblKey.Caption = KeyAscii
End Sub
and got 32 when space bar pressed.

Also, KeyAscii is an integer, so you shouldn't surround the number with quotes.

 
Here's the full ASCII set if you are interested.


Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top