Returns a converted Variant (String) value.
Syntax
StrConv(string, conversion [, LCID])
The StrConv function syntax has these arguments:
| Argument | Description |
|---|---|
string |
Required. The string expression to convert. |
conversion |
Required. An integer. The sum of values that specifies the type of conversion to perform. |
LCID |
Optional. The locale ID, if it's different from the system locale ID. The system locale ID is the default. |
Settings
The conversion argument settings are:
| 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 the string to uppercase. |
vbWide * |
4* | Converts narrow (single-byte) characters in the string to wide (double-byte) characters. |
vbNarrow * |
8* | Converts wide (double-byte) characters in the string to narrow (single-byte) characters. |
vbKatakana ** |
16** | Converts Hiragana characters in the string to Katakana characters. |
vbHiragana ** |
32** | Converts Katakana characters in the string to Hiragana characters. |
vbUnicode |
64 | Converts the string to Unicode by using the default code page of the system. (Not available on Macintosh.) |
vbFromUnicode |
128 | Converts the string from Unicode to the default code page of the system. (Not available on Macintosh.) |
*Applies to East Asia locales.
**Applies to Japan only.
Note
Visual Basic for Applications (VBA) specifies these constants. You can use them anywhere in your code instead of the actual values. You can combine most constants. For example, use vbUpperCase + vbWide. Don't combine constants that are mutually exclusive. For example, don't use vbUnicode + vbFromUnicode. The vbWide, vbNarrow, vbKatakana, and vbHiragana constants cause run-time errors when you use them in locales where they don't apply.
The following are valid word separators for proper casing: Null (Chr$(0)), horizontal tab (Chr$(9)), line feed (Chr$(10)), vertical tab (Chr$(11)), form feed (Chr$(12)), carriage return (Chr$(13)), and space (SBCS) (Chr$(32)). For DBCS, the actual value for a space varies by country or region.
Remarks
When you're converting a Byte array in ANSI format to a string, use the StrConv function. When you're converting the same kind of array in Unicode format, use an assignment statement.
Query examples
| Expression | Results |
|---|---|
SELECT StrConv(ProductDesc,1) AS Expr1 FROM ProductSales; |
Converts values from the ProductDesc field to uppercase and displays them in the Expr1 column. |
SELECT StrConv(ProductDesc,2) AS LowercaseID FROM ProductSales; |
Converts values from the ProductDesc field to lowercase and displays them in the LowercaseID column. |
VBA example
Note
The following examples show how to use this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search, and then enter one or more terms in the search box.
This example uses the StrConv function to convert a Unicode string to an ANSI string.
Dim i As Long
Dim x() As Byte
x = StrConv("ABCDEFG", vbFromUnicode) ' Convert string.
For i = 0 To UBound(x)
Debug.Print x(i)
Next