String Statement
Declares variables of type String. (Character-string variables)
Syntax
String varName$ [(subscripts)] [, varName$ [(subscripts)]...]
Parameters
- varName$
- Specify the string type and the name of the variable to be declared. subscripts: Optional. Dimensions of an array variable; up to 3 dimensions may be declared. The subscripts syntax is as follows
(ubound1, [ubound2], [ubound3])
ubound1, ubound2, ubound3 each specify the maximum upper bound for the associated dimension. The elements in each dimension of an array are numbered from 0 and the available number of array elements is the upper bound value + 1. When specifying the upper bound value, make sure the number of total elements is within the range shown below:- Local variable: 200
- Global Preserve variable: 400
- Global variable and module variable: 10,000
Description
The String statement is used to declare variables of type String. String variables can contain up to 255 characters. Local variables should be declared at the top of a function. Global and module variables must be declared outside functions.
String Operators
The following operators can be used to manipulate string variables:
+: Merges character strings together. Can be used in the assignment statements for string variables or in the Print instruction.
Example: name$ = fname$ + " " + lname$=: Compares character strings. True is returned when the two strings exactly match, including uppercase and lowercase.
Example: If temp1$ = "A" Then GoSub test< >: Compares character strings. True is returned when one or more characters in the two strings are different.
Example: If temp1$ <> "A" Then GoSub test
Note
Variable Names Must Include "$" Character:
Variables of type String must have the character "$" as the last character in the variable name.
See Also
Boolean Statement, Byte Statement, Double Statement, Global Statement, Int32 Statement, Int64 Statement, Integer Statement, Long Statement, Real Statement, Short Statement, UByte Statement, UInt32 Statement, UInt64 Statement, UShort Statement
String Statement Example
String password$
String A$(10) 'Single dimension array of string
String B$(10, 10) 'Two dimension array of string
String C$(5, 5, 5) 'Three dimension array of string
Print "Enter password:"
Input password$
If UCase$(password$) = "EPSON" Then
Call RunMaintenance
Else
Print "Password invalid!"
EndIf