In Classic ASP, UCase() converts text to uppercase and LCase() converts text to lowercase. These VBScript functions change letter case while leaving numbers, spaces and punctuation unchanged. They return the converted value; to update a variable, assign the result back to it.
Here is a complete example you can save in an .asp file and run on IIS:
<%
Dim my_string
my_string = "Welcome to Plus2net.com"
Response.Write UCase(my_string) & "<br>"
Response.Write LCase(my_string)
%>
Output:
WELCOME TO PLUS2NET.COM
welcome to plus2net.com
Pass a string expression to either function. Both accept a quoted string or a variable containing text.
UCase(string)
LCase(string)
| Function | Purpose | Example | Result |
|---|---|---|---|
UCase() | Convert lowercase letters to uppercase | UCase("Hello ASP") | HELLO ASP |
LCase() | Convert uppercase letters to lowercase | LCase("Hello ASP") | hello asp |
The conversion follows the script runtime's language and locale handling. For language-specific text, test with the languages your application actually receives.
This preserves the original Plus2Net example. It displays the original string, changes it to uppercase, and displays the converted value.
<%
Dim my_string
my_string="Welcome to Plus2net.com"
Response.Write my_string
my_string=UCase(my_string)
Response.Write "<br>After changing to upper case = " & my_string
%>
Welcome to Plus2net.com
After changing to upper case = WELCOME TO PLUS2NET.COM
UCase() is useful for showing headings, labels, or standardized display text in capital letters. It does not permanently change a database value unless your program explicitly saves the result.
LCase() converts uppercase letters to lowercase. The original short example is my_string=LCase(my_string); here it is shown as a complete, independently runnable script.
<%
Dim my_string
my_string = "Welcome to Plus2net.com"
Response.Write my_string
my_string = LCase(my_string)
Response.Write "<br>After changing to lower case = " & my_string
%>
Welcome to Plus2net.com
After changing to lower case = welcome to plus2net.com
You can call both functions on the same original variable without overwriting it. This makes it easy to inspect their results side by side.
<%
Dim my_string
my_string = "Classic ASP 2026"
Response.Write "Original: " & my_string & "<br>"
Response.Write "Uppercase: " & UCase(my_string) & "<br>"
Response.Write "Lowercase: " & LCase(my_string)
%>
Original: Classic ASP 2026
Uppercase: CLASSIC ASP 2026
Lowercase: classic asp 2026
Case conversion affects letters, not digits or punctuation. The following example keeps spaces, 123, @ and ! unchanged.
<%
Dim my_string
my_string = "ASP 123 @ Plus2net!"
Response.Write UCase(my_string) & "<br>"
Response.Write LCase(my_string)
%>
Output: ASP 123 @ PLUS2NET! and asp 123 @ plus2net!.
Use Request.Form() to read a submitted value, and apply UCase() or LCase() before displaying the result. This self-contained Classic ASP example accepts text from a visitor and displays both versions. The output uses Server.HTMLEncode() so visitor-entered HTML is not interpreted as markup.
<%
Dim userText
userText = Trim(Request.Form("user_text"))
%>
<form method="post" action="">
<label for="user_text">Enter text</label>
<input type="text" id="user_text" name="user_text" required>
<button type="submit">Convert</button>
</form>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Response.Write "<p>Uppercase: " & Server.HTMLEncode(UCase(userText)) & "</p>"
Response.Write "<p>Lowercase: " & Server.HTMLEncode(LCase(userText)) & "</p>"
End If
%>
When searching for a category or matching simple text labels, combining Trim() and LCase() can remove surrounding spaces and normalize letter case.
<%
Dim category
category = " ASP Tutorials "
category = LCase(Trim(category))
Response.Write category
%>
Output: asp tutorials. This changes the variable for subsequent operations but does not rewrite the original source or previously stored data.
If your goal is only to check whether two strings match without regard to letter case, StrComp() with vbTextCompare expresses that intention directly. A return value of 0 means the strings compare equal.
<%
Dim firstValue, secondValue
firstValue = "Plus2Net"
secondValue = "plus2net"
If StrComp(firstValue, secondValue, vbTextCompare) = 0 Then
Response.Write "The strings match"
Else
Response.Write "The strings do not match"
End If
%>
Output: The strings match. For a case-sensitive comparison use vbBinaryCompare instead. The values of firstValue and secondValue remain unchanged.
Both UCase() and LCase() return Null when their argument is Null. Check with IsNull() before combining a possibly null value with other strings. Empty strings ("") remain empty.
<%
Dim my_string
my_string = Null
If IsNull(my_string) Then
my_string = ""
End If
Response.Write "Uppercase: " & UCase(my_string) & "<br>"
Response.Write "Lowercase: " & LCase(my_string)
%>
Uppercase:
Lowercase:
Use IsNull() to check database fields or optional values that can actually be Null. A zero-length string is different from Null in VBScript.
| Problem | Explanation and solution |
|---|---|
| Text still displays in the original case | Assign the converted result back to the variable, or output UCase(value)/LCase(value) directly. |
| Form input appears unchanged | Check the input's name and that you are reading the same key with Request.Form("user_text"). |
| Null value causes unexpected output | Test for Null with IsNull() and choose an appropriate fallback. |
| Comparison produces unexpected results | Use StrComp(..., vbTextCompare) for a case-insensitive text comparison. Use Trim() separately if surrounding spaces should be ignored. |
| Unusual results for non-English letters | Case conversion can depend on language and locale behavior. Test actual multilingual input instead of assuming every language converts identically. |
UCase() converts letters to uppercase, while LCase() converts letters to lowercase.
No. They return converted values. To update a variable, assign the result back, for example my_string = UCase(my_string).
No. Digits, punctuation and spaces remain unchanged.
You can normalize both values first, but StrComp() with vbTextCompare is more explicit when comparing text without changing either original value.
The result is Null. Use IsNull() when reading optional or database-backed values.
Yes. Read the value using Request.Form(), convert it, validate it, and use Server.HTMLEncode() before displaying user-controlled text in HTML.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.