In VB, letters are stored in ASCII form, and the ASCII values of uppercase and lowercase letters differ by 32. In this case, if the ASCII value of an uppercase letter plus 32 will become the corresponding lowercase letter, and the ASCII value of the lowercase letter minus 32 will be changed to uppercase letters. The source code for realizing case conversion in VB is as follows:
'Convert uppercase letters to lowercase letters
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 65 And KeyAscii <= 90 Then
KeyAscii = KeyAscii + 32
End If
End Sub
'Convert lowercase letters to uppercase letters
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If
End Sub