LCase - VBScript
Overview
The LCase command converts all characters in a string to lowercase. It is useful for ensuring consistent data formatting, comparing strings in a case-insensitive manner, and manipulating text for readability purposes.
Syntax
LCase(string)
Parameters:
- string: The string to convert to lowercase.
Options/Flags
None
Examples
Simple Conversion:
MsgBox LCase("Hello World")
Output: “hello world”
Case-Insensitive Comparison:
If LCase("apples") = LCase("APPLES") Then
MsgBox "Strings are equal (case-insensitive)"
End If
Common Issues
- Make sure the input string is within the allowed character limit. Extremely long strings may result in errors.
Integration
Concatenation with UCase: Convert a string to lowercase and then concatenate it with an uppercase string:
Dim combined = LCase("Hello") & " " & UCase("World")
Result: “hello WORLD”
Comparison with InStr: Perform a case-insensitive search using the InStr function:
If InStr(1, LCase("My Text"), "find this") > 0 Then
MsgBox "String contains the search term (case-insensitive)"
End If
Related Commands
- UCase: Converts strings to uppercase
- StrComp: Compares strings in a case-sensitive manner
- StrConv: Converts strings between different character sets