How can I stop certain symbols such as / \ : * ? < > | from being used in a text box?
Jonathon.
Printable View
How can I stop certain symbols such as / \ : * ? < > | from being used in a text box?
Jonathon.
Edit them out something like this
private Sub Text1_KeyPress(KeyAscii as Integer)
Dim NoWant as string
NoWant = "/ \ : * ? < > "
If NoWant Like "*" & Chr$(KeyAscii) & "*" then KeyAscii = 0
End Sub
John G
You might want to remove the spaces from the string "NoWant"?
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
Got a point there
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Did not notice that. It appears to be a flaw in Cut and Paste because I cut and pasted that string directly from the original post which does not have the spaces.
Will try it again to see what happens.
John G
I lied. The original post does have the spaces.
John G
Yeahyeah, blame it on someone else ;)
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Thanks John,
Tried it, and it works perfecly,
Jonathon.
on keypress event
u can check its keyascii
suppose u want to cancel "a space" who's keyascii=32
if keyascii=32 then
keyascii=0
end if
or else if u dont know the keyascii then
if(keyascii=asc("/")) then
keyascii=0
end if
best of luck