StrConv Function

Named Arguments

Yes

Syntax

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.

Return Value

A Variant of subtype 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 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 ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.