Tools Links Login

L/UCaseKeyPress

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.

Original Author: Edmundo T. Mendiola

Inputs

KeyAscii As Integer
The ASCII value of key pressed; parameter from KeyPress event.

Assumptions

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.

Returns

Returns the new value of KeyASCII to be returned by the KeyPress event.

Code

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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 78 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Comments

No comments have been added for this post.

You must be logged in to make a comment.