StrConv Function

   
StrConv Function

Class

Microsoft.VisualBasic.Strings

Syntax

 StrConv(   str, conversion   [,   localeID   ]) 
str (required; String)

The string expression to convert

conversion (required; Constant of the VbStrConv enumeration)

One of the constants listed in Section

localeID (optional; Integer)

The locale identifier to use for the conversion

Return Value

A String converted according to conversion

Description

Performs special conversions on a string

Rules at a Glance

  • The following intrinsic conversion constants specify the type of conversion to perform:

Constant

Converts...

 VbStrConv.UpperCase 

The entire string to uppercase.

 VbStrConv.LowerCase 

The entire string to lowercase.

 VbStrConv.ProperCase 

The first letter of every word in str to an uppercase character.

 VbStrConv.Wide 

Narrow (single-byte) characters in str to wide (double-byte) characters.

 VbStrConv.Narrow 

Wide (double-byte) characters in str to narrow (single-byte) characters.

 VbStrConv.Katakana 

Hiragana characters in str to Katakana characters.

 VbStrConv.Hiragana 

Katakana characters in str to Hiragana characters.

 VbStrConv.LinguisticCasing 

Uses linguistic rules for casing . Can be used only with UpperCase and LowerCase .

 VbStrConv.None 

Performs no conversion on str .

 VbStrConv.SimplifiedChinese 

Traditional Chinese characters in str to Simplified Chinese.

 VbStrConv.TraditionalChinese 

Simplified Chinese characters in str to Traditional Chinese.

  • You can combine some of these constants by adding them together or using a logical OR . For example:

     VbStrConv.UpperCase + VbStrConv.Wide 

    The only restriction is that the constants must be mutually exclusive. For example, specifying the value:

     VbStrConv.UpperCase Or VbStrConv.ProperCase   ' Error 

    produces an error.

  • VbStrConv.Katakana and VbStrConv.Hiragana only apply to locales in Japanese. Use of these constants on systems using other locales generates runtime error 5, "Invalid procedure call or argument."

  • VbStrConv.Wide and VbStrConv.Narrow only apply to locales in the Far East. Use of these constants on systems using other locales will generate a runtime error.

  • When determining the start of a new word to convert to proper case, StrConv recognizes the following characters as word separators:

    • Null Chr$(0)

    • Horizontal Tab Chr$(9)

    • Line-feed Chr$(10)

    • Vertical Tab Chr$(11)

    • Form Feed Chr$(12)

    • Carriage Return Chr$(13)

    • Space Chr$(32)

Programming Tips and Gotchas

If you convert to proper case, StrConv converts the first letter of each word to uppercase regardless of whether that word is significant. Hence, "this is the time" becomes "This Is The Time," even though "the" ordinarily would not be capitalized.

VB.NET/VB 6 Differences

Two conversion values supported by VB 6, VbUnicode and VbFromUnicode , have no equivalent in the VbStrConv enumeration. As a result, the function can no longer be used to convert ASCII to Unicode or Unicode to ASCII.

See Also

StrComp Function, StrDup Function, StrReverse Function

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net