textbox's keypress event, look for ctrl+v

Status
Not open for further replies.

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
i know this has to be simple but i can find anything anywhere tonight on how to check if while a textbox has focus if the ctrl+v or ctrl+c was pressed i simply need to use it like such:

VB.NET:
If Asc(e.KeyChar) <> Keys.ControlKey + Keys.V Then
	  Call KeyPressName(sender, e, False)
End If

i know that's wrong, but does it make sense?
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Use the keyup/down to set a bool for Ctrl. Then in the keypress check for v or c & bool.
 

anooprh

New member
Joined
Nov 8, 2011
Messages
1
Programming Experience
3-5
textbox's keypress event validation

If (e.KeyChar >= "0" And e.KeyChar <= "9") Or _
(e.KeyChar >= "a" And e.KeyChar <= "z") Or _
(e.KeyChar >= "A" And e.KeyChar <= "Z") Or e.KeyChar = "-" Or e.KeyChar = "." Or _
e.KeyChar = ChrW(Keys.Delete) Or e.KeyChar = ChrW(Keys.Back) _
Or e.KeyChar = ChrW(Keys.Space) Or e.KeyChar = "/" Or e.KeyChar = ChrW(22) Then
Else
e.Handled = True
End If
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
If (e.KeyChar >= "0" And e.KeyChar <= "9") Or _
(e.KeyChar >= "a" And e.KeyChar <= "z") Or _
(e.KeyChar >= "A" And e.KeyChar <= "Z") Or e.KeyChar = "-" Or e.KeyChar = "." Or _
e.KeyChar = ChrW(Keys.Delete) Or e.KeyChar = ChrW(Keys.Back) _
Or e.KeyChar = ChrW(Keys.Space) Or e.KeyChar = "/" Or e.KeyChar = ChrW(22) Then
Else
e.Handled = True
End If
That is an incredibly bad way to handle things. Plus this is a 6.5 year old thread.
 
Status
Not open for further replies.
Top Bottom