Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

VBA String Operator

The string data is used to hold a sequence of characters that can consist of numbers, alphabets, special characters (symbols) or all of them.

String operators are used to manipulating string data.

A variable is said to be a string if it is enclosed within double quotes ("").

Syntax

Examples

You can concatenate the value of Mar-1997 from the first three letters of the month and the year like "Mar-1997".

Here are some string operators such as:

1. Concatenate (&): This operator is used to concatenate the two strings or values together.

For example, "Mary" & "Kom".

Output: MaryKom

Note: Concatenation operator can be used for the numbers as well as strings. The output depends on the context if the variables hold string value or a numeric value.

Example

Step 1: First add a Button to the excel sheet as we have shown earlier.

  1. Change the name property such as btnconcatenate.
VBA String Operator

Step 2: Right-click on the button.

Step 3: Select View Code option.

Step 4: You will get the code window as shown in the below screenshot.

VBA String Operator

Step 5: Write the following code in between Private Sub btnAdd_Click and End Sub as follows:


VBA String Operator

Step 6: Click on the Save button.

Step 7: And close the code editor window.

Step 8: Then turn off the Design Mode button.

VBA String Operator

Step 9: The indicator is, it will change into a white background from the greenish colored background, as shown in the below screenshot.

VBA String Operator

Step 10: Click on the Concatenate button.

Step 11: Execute the above code, and you will get the output as shown in the below screenshot.

VBA String Operator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA