Q: How can I translate all input to uppercase?
Depending on how the control is used, one of the following methods will translate all input to uppercase.
Masked Edit Control
If you are using a mask (defined by the Mask property), you can use the <u token (see Special Handling Tokens in the Mask property documentation).
Example:
SftMask2.Mask = "<u???>-???"
SftMask2.Caption.Text = "Part No."
Simple Edit Control
If you are not using a mask (i.e., you are using the control as a simple edit control) you can translate input in the KeyPress event as follows:
Private Sub SftMask1_KeyPress(KeyAscii As Integer)
Dim s As String
s = Chr(KeyAscii)
s = UCase(s)
KeyAscii = Asc(s)
End Sub
This technique could also be used to limit input to digits only in a simple edit control:
Private Sub SftMask1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
|