QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

Concatenation is a process where literal or variable STRING values are combined using the + operator.

Usage

value$ = “Literal text” + string_variable$ + “more text.”

Adding quotation marks to a string value using concatenation. Variables cannot be defined using semicolons!


quote$ = CHR$(34) + "Hello World!" + CHR$(34)

PRINT "Bill Gates never said "; quote$; " when he answered the telephone!"


Bill Gates never said "Hello World!" when he answered the telephone!

Inserting numerical values in a PRINT string with semicolons, PRINT USING and PRINT with concatenation.


name$ = "Billy"
boxes% = 102
sales! = 306.00
template$ = "& sold ### boxes for $$####,.##."

PRINT name$; " sold"; boxes%; "boxes for $"; sales!; "."
PRINT USING template$; name$; boxes%; sales!
PRINT name$ + " sold" + STR$(boxes%) + " boxes for $" + LTRIM$(STR$(sales!)) + "." 


Billy sold 102 boxes for $ 306 .
Billy sold 102 boxes for $306.00.
Billy sold 102 boxes for $306.

Explanation: Printed numerical values using semicolons have a space on each side. PRINT USING properly formats the string and displays the cent values when they are zero. STR$ converts the number to a string and excludes the right number space, but leaves the sign space. LTRIM$ eliminates the leading sign space between the string number and the $ dollar sign.

See Also