The
VBA StrConv Function
(This is an abbreviated form of
"VBA Help" showing only what is needed for now.)
The StrConv function converts a
text string
from its current format to another format.
For example, from all UPPER CASE to
all lower case,
or from all UPPER CASE or lower
case, to Proper Case.
Syntax
:
StrConv(string,
conversion, LCID) ß
Form 1
StrConv(string,
conversion) ß Form 2 : Use this form without
the “LCID”
The
StrConv function syntax has these named arguments:
LCID - You can ignore this one for now (use form 2, shown above.)
String : The first 'argument' in the 'argument list' is the text string you
want to convert.
This can be
'literal' string like "JOHN" or a text string stored in a variable or
a field in a record.
conversion : The second 'argument' is the type of
conversion you want to perform.
The second 'argument' is
specified by a number that you get from this list :
Constant Value Description
VbUpperCase 1 Converts the string to uppercase
characters.
VbLowerCase 2 Converts the string to lowercase
characters.
VbProperCase 3 Converts the first letter of every word in
string to uppercase.
Examples : (Note that the second
argument can either be an number or a word. See Note below for details.)
StrConv(“john”, 1) or StrConv(“john”, vbUpperCase) converts to “JOHN”
StrConv(“John”, 1) or StrConv(“JoHn”, vbUpperCase) converts to “JOHN”
StrConv(“JOHN”, 2) or StrConv(“JoHn”, vbLowerCase) converts to “john”
StrConv(“JOHN”, 3) or StrConv(“JoHn”, vbProperCase) converts to
“John”
Note
These constants are defined by VBA
and can be used anywhere in your code.
In other words, you may use the VB
keyword vbProperCase
anywhere in your code in place of
the number 3.
This may be harder to
type, but is easier to remember.