by Edmundo T. Mendiola (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)
Use these functions in KeyPress events to format user entries as entry is typed. UCaseKeyPress() converts key pressed to uppercase while LCaseKeyPress() converts key pressed to lowercase.
Inputs
KeyAscii As Integer
The ASCII value of key pressed; parameter from KeyPress event.
Assumes
These two functions are easily re-usable in any projects where form controls with KeyPress events exists. You may also use this function in situations where the equivalent upper or lower case ASCII value of a character is to be evaluated.
Code Returns
Returns the new value of KeyASCII to be returned by the KeyPress event.
Public Function LCaseKeyPress(ByRef KeyAscii As Integer) As Integer
' Useful in the KeyPress event to convert entry to LCase()
LCaseKeyPress = Asc(LCase(Chr(KeyAscii)))
End Function
Public Function UCaseKeyPress(ByRef KeyAscii As Integer) As Integer
' Useful in the KeyPress event to convert entry to UCase()
UCaseKeyPress = Asc(UCase(Chr(KeyAscii)))
End Function