UCase - VBScript


Overview

The UCase command in VB Script converts all lowercase characters in a given string to uppercase. It is commonly used for data normalization, text manipulation, and string comparisons.

Syntax

UCase(string)

Arguments:

  • string: The string to be converted to uppercase.

Options/Flags

None.

Examples

Simple Example:

Dim myString = "hello world"
Dim upperString = UCase(myString)
' upperString will contain "HELLO WORLD"

Complex Example:

Dim myText = "This is a MiXeD cASE String."
Dim normalizedText = UCase(Replace(myText, " ", ""))
' normalizedText will contain "THISISAMIXEDCASESTRING."

Common Issues

  • Error if Missing Argument: If the string argument is not provided, an error will be thrown.
  • No Case Conversion for Non-Alphabetic Characters: UCase only affects alphabetic characters. Non-alphabetic characters, such as numbers and symbols, remain unchanged.

Integration

Combining with Other Commands:

  • LCase: Can be used to convert a string to lowercase.
  • StrComp: Can be used to compare two strings after converting them to the same case for case-insensitive comparisons.
  • LCase
  • StrComp
  • StrConv