UCase() and LCase() in Classic ASP

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

Syntax of UCase() and LCase()

Pass a string expression to either function. Both accept a quoted string or a variable containing text.

UCase(string)
LCase(string)
FunctionPurposeExampleResult
UCase()Convert lowercase letters to uppercaseUCase("Hello ASP")HELLO ASP
LCase()Convert uppercase letters to lowercaseLCase("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.

Convert a string to uppercase with UCase()

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
%>

Output

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.

Convert a string to lowercase with LCase()

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
%>

Output

Welcome to Plus2net.com
After changing to lower case = welcome to plus2net.com

Compare UCase() and LCase() on the same input

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

What happens to numbers, spaces and punctuation?

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!.

Convert text submitted through an HTML form

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
%>
Form-handling note: Case conversion does not validate a submitted value. Check required fields, length, and expected characters on the server before storing data. Keep the original text if capitalization is meaningful, such as a person's name.

Normalize text before comparing or searching

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.

Compare strings without changing either one

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.

Handle Null and empty strings

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.

Troubleshooting

ProblemExplanation and solution
Text still displays in the original caseAssign the converted result back to the variable, or output UCase(value)/LCase(value) directly.
Form input appears unchangedCheck the input's name and that you are reading the same key with Request.Form("user_text").
Null value causes unexpected outputTest for Null with IsNull() and choose an appropriate fallback.
Comparison produces unexpected resultsUse StrComp(..., vbTextCompare) for a case-insensitive text comparison. Use Trim() separately if surrounding spaces should be ignored.
Unusual results for non-English lettersCase conversion can depend on language and locale behavior. Test actual multilingual input instead of assuming every language converts identically.

Frequently asked questions

What is the difference between UCase() and LCase() in Classic ASP?

UCase() converts letters to uppercase, while LCase() converts letters to lowercase.

Do UCase() and LCase() change the original string variable?

No. They return converted values. To update a variable, assign the result back, for example my_string = UCase(my_string).

Do these functions change digits, symbols or spaces?

No. Digits, punctuation and spaces remain unchanged.

Can I use UCase() or LCase() to make a string comparison case-insensitive?

You can normalize both values first, but StrComp() with vbTextCompare is more explicit when comparing text without changing either original value.

What happens if I pass a Null value?

The result is Null. Use IsNull() when reading optional or database-backed values.

Can I convert HTML form input to uppercase or lowercase?

Yes. Read the value using Request.Form(), convert it, validate it, and use Server.HTMLEncode() before displaying user-controlled text in HTML.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer