KeyPress Event — Event Procedures Example
The following example converts text entered in a text box to uppercase as the text is typed in, one character at a time.
To try the example, add the following event procedure to a form that contains a text box named ShipRegion.
Private Sub ShipRegion_KeyPress(KeyAscii As Integer)
Dim strCharacter As String
' Convert ANSI value to character string.
strCharacter = Chr(KeyAscii)
' Convert character to upper case, then to ANSI value.
KeyAscii = Asc(UCase(strCharacter))
End Sub