(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 “all lower case”
or “AlL miXeD cAsE” to “All Proper Case”
(but it doesn’t change the actual letters, just the case !)
Syntax
:
Form 1 : StrConv(string,
ConversionType, LCID) ß
uses 3 arguments (LCID is the location ID,
which we don’t need)
Form 2 : StrConv(string,
ConversionType) ß uses
2 arguments : Use this form without the “LCID”
The
StrConv function syntax has these Named Constants:
LCID - You can ignore this argument for now (use form 2 with
only the 1st 2 arguments, as 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.
ConversionType : 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 :
(Click here for more about Named
Constants)
Please NOTE that these named constants may not be available in
the Access QBE grid.
VbUpperCase (Actual
value = 1) All uppercase characters.
VbLowerCase (Actual
value = 2) All lowercase characters.
VbProperCase (Actual
value = 3) First letter of every word
to uppercase.
Please NOTE that these named constants may not be available in
the Access QBE grid.
|
VBA “Named Constant” |
Actual value |
Purpose |
|
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”
“JOHN”
StrConv(“JoHn”, 1) or StrConv(“JoHn”, vbUpperCase) converts to “JoHn”
“JOHN”
StrConv(“JoHn”, 2) or StrConv(“JoHn”, vbLowerCase) converts to “JoHn”
“john”
StrConv(“JoHn”, 3) or StrConv(“JoHn”, vbProperCase) converts to
“JoHn” “John”
The VB constant vbProperCase vbUpperCase or vbLowerCase simply
replaces the number value.
Whether you use the number or the equivalent constant makes no
difference at all.
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.