Bananafish
Apr 2nd, 2002, 09:56 AM
I wish to Validate entry in a textbox so that only uppercse text is entered. If Lowercase text i sentered I wish to convert it automatically to uppercase.
In vb6 - I could use the keypress event with keyascii.
For example - to convert to uppercase.
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If
Looking at .net - I can do something similar,
Private Sub txtJobCode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtJobCode.KeyPress
If e.KeyChar.IsLower(e.KeyChar) Then
e.KeyChar.ToUpper(e.KeyChar)
End If
End Sub
but I can't figure out how to reset the key that was pressed (The above example, doesnt change what was entered in the text box).
any ideas?
In vb6 - I could use the keypress event with keyascii.
For example - to convert to uppercase.
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If
Looking at .net - I can do something similar,
Private Sub txtJobCode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtJobCode.KeyPress
If e.KeyChar.IsLower(e.KeyChar) Then
e.KeyChar.ToUpper(e.KeyChar)
End If
End Sub
but I can't figure out how to reset the key that was pressed (The above example, doesnt change what was entered in the text box).
any ideas?