If you need to concatenate two or more strings, use the + operator.
strFirst = "John"; strLast = "Kennedy"; strFull = strFirst + "F." strLast;
- If you place a quotation mark within a string, it may cause an error. To use a quotation mark within a string, use the escape code “.
strQuote = "don "t forget the escape code";
' single quotation mark " double quotation mark back slash r carriage return n new line t tab
An array is list or table of variables of the same data type. For example to create an array containing the names of colors you might use the code below.
strColor = new Array(6); strColor(0) = "black"; strColor(1) = "blue"; strColor(2) = "green"; strColor(3) = "orange"; strColor(4) = "red"; strColor(5) = "white";
Access an element of an array by using its index. For example to access the array element “orange”, use the code below.
strFavorite = strColor(3);
- The first element in the array always has an index of 0. The last element in an array has an index one less than the size used to declare the array.
- You can declare and initialize an array at the same time as shown below.
color = new Array("black", "blue", "green", "orange", "red", "white");
If you don’t know how many elements will be in the array, you can declare it without a size as shown below.
strMembers = new Array();