A string expression consists of string
literals,
"Cats and dogs" ' string constant
firstname$ ' string variable
firstname$ + lastname$ ' string concatenation
a$ = "Cats " & "and " & "dogs" ' string concatenation
LEFT$(a$ + z$,7) ' string function
a$ + MID$("Cats and dogs",5,3)
RIGHT$(MID$(a$ + z$,1,6),3)
Note that fixed-length strings are always a fixed length (defined in the corresponding DIM statement), string concatenation involving these strings works differently than you might expect. For instance, the following program fragment:
DIM Greeting AS STRING * 40
Greeting = "hello"
Greeting = greeting + "there"
This appends (adds) the five-character string "there" to the 40-character fixed-length string ("hello", followed by 35 spaces), but the result is truncated to 40 characters (the predefined length of the string variable Greeting), which causes the newly appended string to be lost. One solution to this problem is to use the RTRIM$ function to remove the trailing spaces from "hello" before appending "there":
DIM Greeting AS STRING * 40
Greeting = "hello"
Greeting = RTRIM$(Greeting) + " there"
Variables of user-defined types may be used as string operands without any need to specify the individual UDT members:
TYPE MyType
ItemOne AS STRING * 10
ItemTwo AS STRING * 10
END TYPE
DIM SomeData AS MyType
SomeData.ItemOne = "hello"
SomeData.ItemTwo = "world!"
X$ = "Look at this!" + $CRLF + SomeData
See Also
Dynamic (Variable-length) strings ($)