Contenido

# Función StrConv

Convert a string as specified by a conversion type.

Esta constante, función u objeto se activa mediante la instrucción Option VBASupport 1, colocada antes del código ejecutable del programa en un módulo.

### Sintaxis:

StrConv(string As String, Conversion As Integer, [ LCID ])

### Valor de retorno:

String

### Parámetros:

string: Any valid string expression.

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

Conversión | Valor | Descripción
--- | --- | ---
vbUpperCase | 1 | Converts Text characters to uppercase.
vbLowerCase | 2 | Converts Text characters lowercase.
vbProperCase | 3 | Convierte la primera letra de cada una de las palabras en Texto en mayúscula.
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 Optional. The Locale ID in decimal number. If this parameter is omitted, it assumes the system Locale ID. Refer to the file msi-encodinglist.txt for the available LCID values.

### Ejemplo:

    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"

        REM Converts narrow (single-byte) characters in string to wide
        Print StrConv("ABCDEVB¥ì¥¹¥¥å©", vbWide) ' = "ＡＢＣＤＥＶＢ￥ì￥¹￥￥å©"

        REM Converts wide (double-byte) characters in string to narrow (single-byte) characters
        Print StrConv("ＡＢＣＤ＠＄％２３＇？ＥＧ", vbNarrow) ' = "ABCD@$%23'?EG"

        REM Converts Hiragana characters in string to Katakana characters
        Print StrConv("かたかな", vbKatakana) ' = "カタカナ"

        REM Converts Katakana characters in string to Hiragana characters
        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 caracteres
        Print x(2) ' = 186
        Print StrConv(x, vbUnicode)' = "ÉÏº£ÊÐABC"
    End Sub

Temas relacionados

Funciones e instrucciones exclusivas de VBA