Modifying String Case

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Font control is not a strong point of VBScript. Regardless of whether you are displaying output in the command window or in a message box, you have no ability to control such font characteristics as style, size, and color. In fact, about the only thing you can do with fonts is modify the case; that is, you can configure a character (or set of characters) to be either uppercase or lowercase.

Modifying string case can be useful in displaying information. By changing case as needed, you can either ensure a consistent look to a data display (for example, all items shown in lowercase letters) or, alternatively, draw attention to specific items. For example, in this hypothetical output it is easy to see which server requires immediate attention:

Server          Status atl-dc-01      Healthy atl-dc-02      Healthy ATL-DC-03      ERROR atl-dc-04      Healthy 

Modifying the case is also useful for data entry. For example, to ensure that users enter states using an all-uppercase format (WA, OR, CA), you can simply take the value they enter, regardless of case, and convert it to all uppercase letters.

The two functions that allow you to modify string case are described in Table 2.15.

Table 2.15   Functions for Modifying String Case

FunctionDescription
LCaseConverts all the alphabetic characters in a string to their lowercase equivalents.

The following lines of code convert the string Arlene Huff to the all-lowercase string arlene huff.

UserName = "Arlene Huff" Wscript.Echo LCase(UserName)
UCaseConverts all the alphabetic characters in a string to their uppercase equivalents.

The following lines of code convert the string Arlene Huff to the all-uppercase string ARLENE HUFF.

UserName = "Arlene Huff" Wscript.Echo UCase(UserName)

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net