Skip to content

Operator String Concatenation

Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › Operators › Operator + (String Concatenation)

Operator + (String Concatenation)

Concatenates two strings

Syntax

Declare Operator + ( ByRef lhs As String, ByRef rhs As String ) As String
Declare Operator + ( ByRef lhs As ZString, ByRef rhs As ZString ) As ZString
Declare Operator + ( ByRef lhs As WString, ByRef rhs As WString ) As WString

Parameters

  • lhs
  • rhs

Description

This operator concatenates two strings. Unlike Operator & (String Concatenation With Conversion) both expressions must be strings, and may not be converted (in fact, any attempt to concatenate a string with a non-string or two non-strings will result in a type mismatch error, with the exception of when operator overloading is used in a UDT).

Remarks

Usage

result = lhs + rhs

Differences from QB

  • None

See also

Examples

Dim As String a = "Hello, ", b = "World!"

Dim As String c

c = a + b

Print c

Output:

Hello, World!

Category: Operators
Kind: operator


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally