Visual Basic Language Reference  

StrConv Function

Returns a string converted as specified.

Public Shared Function StrConv( _
   ByVal Str As String, _
   ByVal Conversion As Microsoft.VisualBasic.VbStrConv, _
   Optional ByVal LocaleID As Integer, 
) As String

Parameters

Str
Required. String expression to be converted.
Conversion
Required. Microsoft.VisualBasic.VbStrConv member. The enumeration value specifying the type of conversion to perform.
LocaleID
Optional. The LocaleID value, if different from the system LocaleID value. (The system LocaleID value is the default.)

Settings

The Conversion argument settings are:

Enumeration member Description
VbStrConv.None Performs no conversion
VbStrConv.LinguisticCasing Uses linguistic rules for casing, rather than File System (default). Valid with UpperCase and LowerCase only.
VbStrConv.UpperCase Converts the string to uppercase characters.
VbStrConv.LowerCase Converts the string to lowercase characters.
VbStrConv.ProperCase Converts the first letter of every word in string to uppercase.
VbStrConv.Wide* Converts narrow (half-width) characters in the string to wide (full-width) characters.
VbStrConv.Narrow* Converts wide (full-width) characters in the string to narrow (half-width) characters.
VbStrConv.Katakana** Converts Hiragana characters in the string to Katakana characters.
VbStrConv.Hiragana** Converts Katakana characters in the string to Hiragana characters.
VbStrConv.SimplifiedChinese* Converts Traditional Chinese characters to Simplified Chinese.
VbStrConv.TraditionalChinese* Converts Simplified Chinese characters to Traditional Chinese.

*   Applies to Asian locales.
**   Applies to Japan only.

Note   These constants are specified in the .NET common language runtime. As a result, they may be used anywhere in your code in place of the actual values. Most can be combined, for example, UpperCase + Wide, except when they are mutually exclusive, for example, VbStrConv.Wide + VbStrConv.Narrow.

The following are valid word separators for proper casing: Null (Chr$(0)), horizontal tab (Chr$(9)), linefeed (Chr$(10)), vertical tab (Chr$(11)), form feed (Chr$(12)), carriage return (Chr$(13)), space (single-byte character set) (Chr$(32)). The actual value for a space varies by country/region for the double-byte character set.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 Unsupported LocaleID, Conversion < 0 or > 2048, or unsupported conversion for specified locale.

Remarks

The constants VbStrConv.Wide, VbStrConv.Narrow, VbStrConv.Simplified Chinese, VbStrConv.Traditional Chinese, VbStrConv.Katakana, and VbStrConv.Hiragana can cause run-time errors when used in locales where they do not apply, but not always: the constants VbStrConv.Katakana and VbStrConv.Hiragana can be used in a non-Japanese system with the Japanese Language Pack installed. In addition, use of the constants VbStrConv.Wide and VbStrConv.Narrow is supported on any system with a double-byte character set (DBCS) language installed.

Example

This example converts text into all lowercase letters.

Dim sText, sNewText As String
sText = "Hello World"
sNewText = StrConv(sText, VbStrConv.LowerCase)
Debug.WriteLine (sNewText)   ' Outputs "hello world".

See Also

Chr, ChrW Functions | String Data Type | Type Conversion Functions | ArgumentException