converting a string to uppercase or lowercase using the API
converting a string to uppercase or lowercase using the API
Start up Visual Basic as usual and enter the code below in the general declarations section of the form.
Option Explicit
Private Declare Function CharLower Lib “user32″ Alias “CharLowerA” (ByVal lpsz As String) As Long
Private Declare Function CharUpper Lib “user32″ Alias “CharUpperA” (ByVal lpsz As String) As Long
Now enter the following in the Form_Load event procedure
Private Sub Form_Load()
Dim strTest As String
Me.AutoRedraw = True
‘test string
strTest = “This is a test string Which is Mixed Case”
Me.Print strTest
‘Convert all the characters to uppercase
CharUpper strTest
Me.Print strTest
‘Convert all the characters to lowercase
CharLower strTest
Me.Print strTest
End Sub
Now run the program (Press F5) and all going well you should see the date and time of your system. Here is what was displayed
on the test system.

Analysis
This uses the CharUpper and CharLower API commands which take a pointer to astring, the string will be hardcoded in and then
converted.
This could be useful for ensuring that a user used only lowercase when entering a username / password combo in an app.
























