StrConv Function

Convert a string as specified by a conversion type.

warning

Deze constante, functie of object, is ingeschakeld met de instructie Option VBASupport, geplaatst voor het uitvoerbare programmacode in een module.


Syntaxis:

StrConv(Text, Conversion, [ LCID ])

Geretourneerde waarde:

String

Parameters:

Text: Any valid string expression.

Conversion: The type of conversion to perform, as defined in the table below.

Conversion

Value

Description

vbUpperCase

1

Converts Text characters to uppercase.

vbLowerCase

2

Converts Text characters lowercase.

vbProperCase

3

Converts the first letter of every word in Text to uppercase.

vbWide

4

Converts narrow (half-width) characters in Text to wide (full-width) characters.

vbNarrow

8

Converts wide (full-width) characters in Text to narrow (half-width) characters.

vbKatakana

16

Converts Hiragana characters in Text to Katakana characters.

vbHiragana

32

Converts Katakana characters in Text to Hiragana characters.

vbUnicode

64

Converts Text characters to Unicode characters using the default code page of the system.

vbFromUnicode

128

Converts Text characters from Unicode to the default code page of the system.


LCID Optioneel. De 'Locale ID' als decimaal getal. Als standaardwaarde dient de systeemwaarde. De beschikbare waarden staan hier: msi-encodinglist.

Voorbeeld:


Option VBASupport 1
Option Explicit
Sub Test_StrConv
    Print StrConv("abc EFG hij", vbUpperCase) '= "ABC EFG HIJ"
    Print StrConv("abc EFG hij", vbLowerCase) ' =  "abc efg hij"
    Print StrConv("abc EFG hij", vbProperCase) ' = "Abc Efg Hij" vbProperCase)")

    REM Converteert halve-breedte tekens naar volledige-breedte tekens
    Print StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide) ' = "ABCDEVB¥ì¥¹¥­¥å©"

    REM Converteert volledige-breedte tekens (2 bytes) naar halve-breedte tekens (byte)
    Print StrConv("ABCD@$%23'?EG", vbNarrow) ' = "ABCD@$%23'?EG"

    REM Converteert Hiragana tekens naar Katakana tekens
    Print StrConv("かたかな", vbKatakana) ' = "カタカナ"

    REM Converteert Katakana tekens naar Hiragana tekens
    Print StrConv("カタカナ", vbHiragana) '= "かたかな"

    REM  Assumes CP-1252 encoding associated with en-US locale used in unit tests.
    Dim x() As Byte
    x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
    Print UBound(x) ' 8 characters
    Print x(2) ' = 186
    Print StrConv(x, vbUnicode)' = "ÉϺ£ÊÐABC"
End Sub