what is it? :-)
Printable View
what is it? :-)
vbKeyBack
.
Ascii code I think its 8.
Hi!
Yes its ascii code is 8
here is a code for finding ascii code for any keypress
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub
try it
pari
Here is all ASCII code with DESCRIPTIONS : http://www.bbsinc.com/iso8859.html
Nice reference link DaoK! :D
thank you guys!
1 more stupid question and i can work on, how can i limit a textbox to, let's say 3 chars?
that just displays key codes not ascii codes,Quote:
Originally posted by pari
Hi!
Yes its ascii code is 8
here is a code for finding ascii code for any keypress
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
End Sub
try it
pari
from memory it is
Private Sub Text1_KeyPress(KeyAscii As Integer, Shift As Integer)
MsgBox KeyAscii
End Sub
;)
Set the "MaxLength" property of the textbox to 3 like this:
VB Code:
Text1.MaxLength = 3
that's the best way, or u could add handling on the keypress.....
:rolleyes:
If you are going to limit the text length at the control level, then you need to code both the KeyPress for keyboard input, and the change event for pasted input. abdul has the easiest suggestion however. If you just set that MaxLength property at design time, then you don't have to worry about either the Change or the KeyPress event. The disadvantage to that is you can't throw a message box or something at the user telling them they have reached the MaxLength.
try this if you want to do what hack says:
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) If Len(Text1) = 3 And KeyAscii <> vbKeyBack Then KeyAscii = 0 MsgBox "You have reached the maximum length :)" Exit Sub End If End Sub
;)
Here is a trick I have when I program when I do not have Internet and I need to know an ASCII number.
Here is the code :
VB Code:
Private Sub Form_Load() For i = 0 To 255 List1.AddItem ("->" & Format(i, "000") & " = " & Chr(i)) Next End Sub
Just add a Listbox and here you go :)
that won't tell you the ascii key for backspace
if anything, you just put in the keypress event
debug.print keyascii
then when you know what key you pressed e.g. backspace, and you find out its ascii code ;)