Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Visual Basic/Strings

From Wikibooks, open books for an open world
<Visual Basic

Visual Basic has a traditional set of built in string operations. Unlike many languages Visual Basic strings are alwaysUnicode so they can hold any character. They are also always dynamically allocated and are of almost unlimited length (theoretically up to about 231 characters, about 2000 million).

Note that Unicode uses more than one byte to represent each character. As far as VB is concerned Unicode characters are two bytes which gives 216 or 65536 possible values. This is enough even for Chinese, Japanese and Korean character sets (CJK). In fact Unicode defines 17 planes each of which has room for 216 code points but VB (and Windows) uses only theBasic Multilingual Plane (BMP).

SeeWhat Are VB Strings? for a concise explanation of the internal workings of Visual Basic Classic strings.

Built In String Functions

[edit |edit source]

Visual Basic provides a reasonable set of traditional functions for manipulating and searching strings. These functions are usually all that is needed for most programs that are not primarily concerned with text processing.

Regular Expressions

[edit |edit source]

A regular expression is a character string in which some characters have special meanings. Such a string can be used to search for substrings in another string in much more sophisticated ways than the built in InStr function.

For example this expression:

 "(dog|cat)"

will match either 'dog' or 'cat'.

Visual Basic has no built in regular expression functions, but these are available in the VBScript regular expression library. If your program does a lot of text processingregular expressions are definitely worth learning even though they may seem intimidating at the start. In practice most programmers find that the more arcane expressions are rarely used and the same idioms are recycled over and over so there is really not as much to learn as it at first appears.


Previous: LoopsContentsNext: Built In String Functions
Retrieved from "https://en.wikibooks.org/w/index.php?title=Visual_Basic/Strings&oldid=4392704"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp