Concatenating Strings In QTP

By xerocube | January 16, 2007

Today’s tech post is in response to a surprising amount of queries asking how to concatenate strings in QuickTest Pro.

First, it is important to remember that QuickTest Pro scripts are written using VBScript. With that in mind, you can investigate many corners of the internet for sample code and examples of VBScript code. Using the simple Google query returns a host of good resources: VBScript Google Search.

Second, let’s tackle to concatenation issue. In order to concatenate, or add, strings together, you must use the + operator.

‘ Example
Dim strTemp
strTemp = “I am a ” + “little teapot.”
‘ Results: “I am a little teapot.”

This next example takes two variables and concatenates them.

‘ Example
Dim strResults
Dim strTemp1
Dim strTemp2
strTemp1 = “Who let the ”
strTemp2 = “dogs out?”
strResults = strTemp1 + strTemp2
‘ Results: “Who let the dogs out?”

Hopes this tidbit of information helps you out.

Topics: Code, QuickTest Pro | 3 Comments »

3 Responses to “Concatenating Strings In QTP”

Rajendra Says:
March 29th, 2007 at 11:59 pm


S.J.PATE Says:
December 12th, 2007 at 11:06 am

I’ve been successfully cocatenating for several months now, have you tried the 3rd keystroke method? Works every time, had some trouble vegitartreing the first time, but now I have the hang of it. Thanx man!!!!

Sudhir Patil Says:
January 27th, 2009 at 2:48 am

In one of aplication, I have drop down box for each Date, Month and Year to select a Travel start date.
After selecting theses fields when we go to the next page the selected date appear as mm/dd/yyyy format on next page as text element.
In QTP i want to verify if the date appearing on the next page is same as we select on first page.

Also if parameterize the dates of first page i want to validated the next page dates.
Can you please help me.