I have a question, how can you disallow the user form pressing spacebar in a textbox? and another thing how can you limit a textbox input only for letters?
Use the function "ONKEYPRESS". Everytime a user presses a key this function/Sub will be called. You can then check what key was pressed and then make the appropriate call if it is a alphanumeric key.
pingpang ,
Why don't U use Key_Press or Key_Down Events. For Example:
------------------
'Code here
If KeyAscii = .... then
KeyAscii = 0
End if
'End Code
------------------
That's simple, do you think so? Ofcourse, may be you have better method.
Good Luck
KieuTV
Why don't You use the onChange event of the textbox?
if you put his in Textbox.text = trim(textbox.text) hitting the spacebar won't affect the text.
A copy and paste-operation would let a space in though, it kind of depends on how idiot-proof you want to build your program.
You will need to use the KeyPress event:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeySpace Then KeyAscii = 0
End Sub [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.