StrConv Function |
Yes
StrConv(string, conversion)
string
Use: Required
Data Type: String
The string expression to convert.
conversion
Use: Required
Data Type: Integer
Sum of constant or numeric values denoting the conversion to apply to string.
A Variant of subtype String converted according to conversion.
Performs special conversions on a string.
The following intrinsic conversion constants specify the type of conversion to perform:
Constant | Value | Converts... |
---|---|---|
vbUpperCase | 1 | the entire string to uppercase. |
vbLowerCase | 2 | the entire string to lowercase. |
vbProperCase | 3 | the first letter of every word in string to an uppercase character. |
vbWide | 4 | narrow (single-byte) characters in string to wide (double-byte) characters. |
vbNarrow | 8 | wide (double-byte) characters in string to narrow (single-byte) characters. |
vbKatakana | 16 | Hiragana characters in string to Katakana characters. |
vbHiragana | 32 | Katakana characters in string to Hiragana characters. |
vbUnicode | 64 | the entire string to Unicode using the default code page of the system. |
vbFromUnicode | 128 | the entire string from Unicode to the default code page of the system. |
You can combine most of these constants by adding them together or using a logical OR. For example:
vbUpperCase + vbUnicode
The only restriction is that the constants must be mutually exclusive. For example:
vbUpperCase Or vbProperCase ' Error
is the type of value that's not permitted.
vbKatakana and vbHiragana apply only to locales in Japan. Use of these constants on systems using other locales generates runtime error 5, "Invalid procedure call or argument."
vbWide and vbNarrow apply only to locales in the Far East. Use of these constants on systems using other locales generates a runtime error.
When determining the start of a new word to perform a conversion to Proper Case, StrConv recognizes the following characters as word separators:
Null: Chr$(0)
Horizontal tab: Chr$(9)
Linefeed: Chr$(10)
Vertical tab: Chr$(11)
Formfeed: Chr$(12)
Carriage return: Chr$(13)
Space: Chr$(32)
This short example demonstrates how to convert a string to an array of bytes, for use in an API function call.
Dim byArray() As Byte Dim sString As String sString = "Some stuff" byArray = StrConv(sSting, vbFromUnicode)
The StrConv function is important when using the Win32 API, since many calls require that Unicode strings be passed to them, or they assign Unicode strings to return variables.