Titles = "Queen"
Name $ = "Elizabeth"
Numeral $ = "I"
Title $ AND Name $ AND. Numeral $ = "Queen Elizabeth I"
Title $6 Name $ AND Numeral $ AND Numeral $ = "Queen Elizabeth II"
The operator also unites a line in that order as they are presented. Therefore, unlike summation of numbers, for merge of lines their sequence is important. With the help also it is possible to add as much as necessary string value. The example with usage already declared above variables is more low resulted:
CurrentQueen $ = Title $ AND Name $ AND Numeral $ AND Numeral $
The computer does not have separate section of storage for text storage, and one more - for numbers. Everything that arrives in storage of the computer, will be transformed to a number format (really - in binary representation). In the program it is marked only that the given section of a random access memory contains the coded text. Normally format for conversion of the text information in numeral is called ASCII (American Standard Code for Information Interchange). The given format appropriates to each character appropriate number in a range from 0 to 255 though Windows cannot display all 255 characters and uses their more restricted dial-up ANSI (American National Standards Institute). Controlling characters, and also tabulation special type or line feed - have numbers to 32. Function value Chr (n) is the character corresponding to number п from format ASCII. The operator
Print Chr (n)
Or displays the character corresponding to code ASCII, a current font, or the special effect depending on type of the controlling character takes place. For example, the operator
Print Chr (227)
Deduces the Greek letter "пи" on the screen if before it value FontType has been installed as MS LineDraw by means of window Propoties or through Code.
The following example uses the code of the character of inverted commas ("), 34, for an output to the screen of the phrase quoted from both sides:
Print Chr (34);
Print "Quoth the raven, nevermore.";
Print Chr (34)
On the screen it will be deduced
"Quoth the raven, nevermore."
Print "'" ' Quoth the raven, nevermore. "" ";
As Visual Basic, unlike many versions BASIC, perceives two characters of inverted commas as one and displays it in expressions with operator Print or by operation with string values.
In Visual Basic there is function Asc which parameter is string value, and the result equals to code ASCII for the first character. If the line empty, function produces an error in runtime (run time error).
Order ASCII/ANSI is used by default Visual Basic at comparing of various lines by means of comparison operators, such as> and <. The Most important place for application of coding ASCII/ANSI is event procedure KeyPress.
In early versions to one of the main methods of usage of function Chr formation of controlling characters for passage to a new line in programs is Visual Basic. Passage to a new line is used by operation with multistring data entry fields or at information adding in a data panel. As well as in old typewriters, for word wrapping it is necessary to do two operations: carriage transfer (carriage return) for reset to the first character of a line, and then line feed for passage to the next line. At usage of function Chr word wrapping looks so:
vbCrLf = Chr (13) + Chr (10)
But now there is a possibility to use the built in constant vbCrLf.
For example, it is necessary to break off a line in a data panel or in a multistring data entry field. Fastest it to implement with usage vbCrLf:
TextString $ = "Visual Basic For Windows" + vbCrLf
TextString $ = TextString $ + "Osborne McGraw-Hill" + vbCrLf
TextString $ = TextString $ + "Berkeley, CA"
Textl. Text = TextString $
By the way, there can be a question: why string values at first "collect", but only then are displayed. The answer is simple: it is one of the main methods of acceleration of operation of programs on Visual Basic.
Similarly it is possible to accelerate data panel formation if in it it is necessary to deduce some lines:
Message $ = "This will be on line 1."
Message = Message $ + vbCrLf + "This will be on line 2."
MsgBox Message $
Except a constant vbcrLf, there are some more other, not less useful built in constants (see the table further). All these constants can be used in programs on Visual Basic instead of appropriate values of functions Chr $ or Chr. However for Microsoft Windows application will be found only by the codes for carriage return, line feed, tab and backspace.
Lines of the fixed length represent the special type of a line further often used. Similar variables form by means of operator Dim. Here an example:
Dim ShortString As String * 10
Dim strShort As String * 10
Back on the content