Microsoft Office Tutorials and References
In Depth Information
Figure 7-2. An InputBox dialog box
The Str function converts a number to a string. For instance:
returns the string 123 . Conversely, the Val function converts a string that represents a
number into a number (so that we can do arithmetic with it, for instance). For example:
returns the number 4.5 and:
Val("1234 Main Street")
returns the number 1234 . Note, however, that Val does not recognize dollar signs or
commas. Thus:
returns 0 , not 12.00 .
The Trim, LTrim, and RTrim functions
The LTrim function removes leading spaces from a string. Similarly, RTrim removes
trailing spaces, and Trim removes both leading and trailing spaces. Thus:
Trim(" extra ")
returns the string extra .
The String and Space functions
The String function provides a way to quickly create a string that consists of a single
character repeated a number of times. For instance:
sText = String(25, "B")
sets sText to a string consisting of 25 Bs. The Space function returns a string consisting
of a given number of spaces. For instance:
sText = Space(25)
sets sText to a string consisting of 25 spaces.
The Like operator and StrCmp function
The Like operator is very useful for comparing two strings. Of course, we can use the
equal sign, as in:
string1 = string2
which is true when the two strings are identical. However, Like will also make a
caseinsensitive comparison or allow the use of pattern matching. The expression:
Search JabSto ::

Custom Search