Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


List of VB string functions

Posted on 2001-06-22
Medium Priority
Last Modified: 2012-05-04
can someone please point me to a list of all the vb 6 string functions in msdn. i cant find anything in there.

thanks = (   u
Question by:uron6342
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

JonFish85 earned 200 total points
ID: 6219645
DBCS String Manipulation Functions

Although a double-byte character consists of a lead byte and a trail byte and requires two consecutive storage bytes, it must be treated as a single unit in any operation involving characters and strings. Several string manipulation functions properly handle all strings, including DBCS characters, on a character basis.

These functions have an ANSI/DBCS version and a binary version and/or Unicode version, as shown in the following table. Use the appropriate functions, depending on the purpose of string manipulation.

The "B" versions of the functions in the following table are intended especially for use with strings of binary data. The "W" versions are intended for use with Unicode strings.

Function Description
Asc Returns the ANSI or DBCS character code for the first character of a string.
AscB Returns the value of the first byte in the given string containing binary data.
AscW Returns the Unicode character code for the first character of a string.
Chr Returns a string containing a specific ANSI or DBCS character code.
ChrB Returns a binary string containing a specific byte.
ChrW Returns a string containing a specific Unicode character code.
Input Returns a specified number of ANSI or DBCS characters from a file.
InputB Returns a specified number of bytes from a file.
InStr Returns the first occurrence of one string within another.
InStrB Returns the first occurrence of a byte in a binary string.
Left, Right Returns a specified number of characters from the right or left sides of a string.
LeftB, RightB Returns a specified number of bytes from the left or right side of a binary string.
Len Returns the length of the string in number of characters.
LenB Returns the length of the string in number of bytes.
Mid Returns a specified number of characters from a string.
MidB Returns the specified number of bytes from a binary string.

The functions without a "B" or "W" in this table correctly handle DBCS and ANSI characters. In addition to the functions above, the String function handles DBCS characters. This means that all these functions consider a DBCS character as one character even if that character consists of 2 bytes.

The behavior of these functions is different when they're handling SBCS and DBCS characters. For instance, the Mid function is used in Visual Basic to return a specified number of characters from a string. In locales using DBCS, the number of characters and the number of bytes are not necessarily the same. Mid would only return the number of characters, not bytes.

In most cases, use the character-based functions when you handle string data because these functions can properly handle ANSI strings, DBCS strings, and Unicode strings.

The byte-based string manipulation functions, such as LenB and LeftB, are provided to handle the string data as binary data. When you store the characters to a String variable or get the characters from a String variable, Visual Basic automatically converts between Unicode and ANSI characters. When you handle the binary data, use the Byte array instead of the String variable and the byte-based string manipulation functions.

For More Information   See the Language Reference for the appropriate function.

If you want to handle strings of binary data, you can map the characters in a string to a Byte array by using the following code:

Dim MyByteString() As Byte
' Map the string to a Byte array.
MyByteString = "ABC"
' Display the binary data.
For i = LBound(MyByteString) to UBound(MyByteString)
   Print Right(" " + Hex(MyByteString(i)),2) + " ,";

DBCS String Conversion
Visual Basic provides several string conversion functions that are useful for DBCS characters: StrConv, UCase, and LCase.

StrConv Function
The global options of the StrConv function are converting uppercase to lowercase, and vice versa. In addition to those options, the function has several DBCS-specific options. For example, you can convert narrow letters to wide letters by specifying vbWide in the second argument of this function. You can convert one character type to another, such as hiragana to katakana in Japanese. StrConv enables you to specify a LocaleID for the string, if different than the system's LocaleID.

You can also use the StrConv function to convert Unicode characters to ANSI/DBCS characters, and vice versa. Usually, a string in Visual Basic consists of Unicode characters. When you need to handle strings in ANSI/DBCS (for example, to calculate the number of bytes in a string before writing the string into a file), you can use this functionality of the StrConv function.

Case Conversion in Wide-Width Letters
You can convert the case of letters by using the StrConv function with vbUpperCase or vbLowerCase, or by using the UCase or LCase functions. When you use these functions, the case of English wide-width letters in DBCS are converted as well as ANSI characters

'End of MSDN

go to the "search" tab, search for "String Functions", and double click the "DBCS String Manipulation Functions" (sort by location and its under Visual Basic"

hope this helps!

Expert Comment

ID: 6219659
Asc function

Chr function

Format function

InStr function

LCase function

Left function

Len function

LTrim function

Mid function

Right function

RTrim function

Space function

StrComp function

String function

Trim function

UCase function


Expert Comment

ID: 6219662
Here is a good link for this as well...


Make sure you look at all 4 pages of the tutorial...
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

ID: 6219670
oops.. forgot
InStrRev function

Author Comment

ID: 6219726
thanks, i really hate the way msdn is organized.

Expert Comment

ID: 6219743
:-) a lot of info (approx 1gb) but not exactly easy to find stuff in it!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question