Friday, September 14, 2012

Example of LCASE function- “AuTOMatIon123_!@#” and 'convert all the upper case letter to lower case like “automation123_!@#”.


'Write a program that mimics the functionality of LCase function.
' For example, your program should take any variable like “AuTOMatIon123_!@#” and
'convert all the upper case letter to lower case like “automation123_!@#”.

'Code
Str = InputBox("String to be lowered")
diff = Asc("a") - Asc("A")

For i = 1 to Len(Str)
If Asc(Mid(Str,i,1))<=Asc("Z") And Asc(Mid(Str,i,1))>=Asc("A")Then
    If Asc(Mid(Str,i,1)) = Asc(" ") Then
    StrLower= StrLower + Mid(Str,i,1)
    End If
    temp= chr(Asc(Mid(Str,i,1))+diff)
    StrLower= StrLower+temp
Else
    StrLower= StrLower + Mid(Str,i,1)
End If
Next
MsgBox StrLower
'End Code

No comments:

Post a Comment