16.2. Fundamentals of Characters and StringsCharacters are the fundamental building blocks of Visual Basic source code. Every program is composed of characters that, when grouped together meaningfully, create a sequence that the compiler interprets as instructions describing how to accomplish a task. In addition to normal characters, a program also can contain character literals, also called character constants. A character literal is a character that is represented internally as an integer value, called a character code. For example, the integer value 97 corresponds to the character literal "a"c, and the integer value 122 corresponds to the character literal "z"c . The letter c following the closing double quote is Visual Basic's syntax for a character literal. Character literals are established according to the Unicode character set, an international character set that contains many more symbols and letters than the ASCII character set (listed in Appendix D). To learn more about Unicode, see Appendix E. A string is a series of characters treated as a single unit. These characters can be uppercase letters, lowercase letters, digits and various special characters: +, -, *, /, $ and others. A string is an object of class String in the System namespace. We write string literals, also called string constants, as sequences of characters in double quotation marks, as follows: "John Q. Doe" "9999 Main Street" "Waltham, Massachusetts" "(201) 5551212" A declaration can assign a String literal to a String variable. The declaration Dim color As String = "blue" initializes String variable color to refer to the String literal object "blue". Performance Tip 16.1
Common Programming Error 16.1
|