Micro Focus QTP (UFT) Forums
how can I store a string with variable in it, in another variable? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: how can I store a string with variable in it, in another variable? (/Thread-how-can-I-store-a-string-with-variable-in-it-in-another-variable)



how can I store a string with variable in it, in another variable? - reejais - 11-11-2010

Hi All,

I have a string like this

Code:
<A href="manage_contact_edit.htm?contactId=newstr>Edit</A>

where newstr is a variable

I want to store the above string in a variable like this

Code:
str = "<A href="manage_contact_edit.htm?contactId=newstr>Edit</A>"

Its giving me an error "Expected End of Statement"

can anybody tell me how to store the above string in a variable?

Thanks in advance.

Regards,
Reema.


RE: how can I store a string with variable in it, in another variable? - A.Saini - 11-11-2010

Hi Reema,

The error is occurring as the number of double quotes is odd in the given statement.

Code:
str = "<A href="manage_contact_edit.htm?contactId=newstr>Edit</A>"


You may try this:

Code:
str = "<A href='manage_contact_edit.htm?contactId=" + newstr + "'>Edit</A>"

Please let me know if still any problem.

Smile


RE: how can I store a string with variable in it, in another variable? - reejais - 11-11-2010

Hi Saini,

The problem is that I want that quotes to be there.

Just one more thing to add to this

how can I write this statement

Do Until (s(i) = " " ")
Loop

The problem is " here.... I want to compare S(i) with "

How can I write this?

Thanks
Reema.


RE: how can I store a string with variable in it, in another variable? - rajeshwar - 11-11-2010

Hi Reema,

Work around Smile

Strore <A href="manage_contact_edit.htm?contactId=newstr>Edit</A> in datatable and fetch it from there
Code:
str = DataTable.Value("A",1)
msgbox str

Thanks,

Rajeshwar


RE: how can I store a string with variable in it, in another variable? - smeepaga - 11-11-2010

Work around Smile

try:
Code:
str = "<A href=" & chr(34) & "manage_contact_edit.htm?contactId=newstr>Edit</A>"

Here I am using the ASCII code of double quote, 34.

Try:
MsgBox str

To see the value of str