COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button
VB SCRIPT CONCATENATION OPERATORS
The Concatenation Operators
VBScript supports the following Concatenation operators:
Assume variable A holds 5 and variable B holds 10 then:
Operator Description Example
+ Adds two Values as Variable
Values are Numeric A + B will give 15
& Concatenates two Values A & B will give 510
Example
Try the following example to understand the Concatenation operator available in VBScript:
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
Dim a : a = 5
Dim b : b = 10
Dim c
c=a+b
Document.write ("Concatenated value:1 is " &c) 'Numeric addition
Document.write ("<br></br>") 'Inserting a Line Break for readability
c=a&b
Document.write ("Concatenated value:2 is " &c) 'Concatenate two numbers
Document.write ("<br></br>") 'Inserting a Line Break for readability
</script>
</body>
</html>
When you save it as .html and execute it in Internet Explorer,
then the above script will produce the following result:
Concatenated value:1 is 15
Concatenated value:2 is 510
Concatenation can also be used for concatenating two strings.
Assume variable A="Microsoft" and variable B="VBScript" then:
Operator Description Example
+ Concatenates two Values A + B will give MicrosoftVBScript
& Concatenates two Values A & B will give MicrosoftVBScript
Example
Try the following example to understand the Concatenation operator available in VBScript:
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
Dim a : a = "Microsoft"
Dim b : b = "VBScript"
Dim c
c=a+b
Document.write ("Concatenated value:1 is " &c) 'Numeric addition
Document.write ("<br></br>") 'Inserting a Line Break for readability
c=a&b
Document.write ("Concatenated value:2 is " &c) 'Concatenate two numbers
Document.write ("<br></br>") 'Inserting a Line Break for readability
</script>
</body>
</html>
When you save it as .html and execute it in Internet Explorer,
then the above script will produce the following result:
Concatenated value:1 is MicrosoftVBScript
Concatenated value:2 is MicrosoftVBScript