- The Fundamentals of VBScript
- VBScript Versus VB
- Creating Variables in VBScript
- Concatenating Strings
- Arrays and Loops
- Resizing Arrays
- Inequality Operators
- Conditional Statements
- Select Case Statements
- Sub
- Function
- Working with Arguments
- Beware of Types
- Event Procedure Naming Syntax
- Server-Side Events
- Local Variables
- Script-Level Variables
Concatenating Strings
You can combine strings together and assign them to a variable by using the string concatenation operator, the ampersand, &, as follows:
s = "This is " & "really cool"
Also, in VBScript you can use the plus sign (+) to concatenate strings. The following code is quite valid:
s = "This is " + "really cool"
However, be advised that if you do use the plus sign, you do run the risk of error. The following code will cause an error in the script:
s = "This is " + 5
In the previous example, the raw data is made up of two primitive types, a string ("This is ") and an integer (5). The plus sign does not know how to reconcile the two different types to get them to work together. However, the ampersand has enough built-in smarts to reconcile the two different data types. Thus, this code works perfectly well:
s = "This is " & 5