I had a scenario where i had to display the message as – The operaration cannot be performed because “xyz” field is blank. To include double quotes in the QTP message or string
Now if i try to store the above message in a string as –
1: string1 = "The operaration cannot be performed because "xyz" field is blank."
2: msgbox string1
We get the following error on running the above code in QTP.
There are two ways to handle this problem:-
1. Double the quotes (“”):
Use 2 double quotation marks to include a quote character in the string.
1: String1 = "The operaration cannot be performed because ""xyz"" field is blank."
2: msgbox string1
The result is:
2. Use ANSI character code – Chr(34):
Since, the ANSI code if quotation mark = 34, we can use Chr function.
1: string1 = "The operaration cannot be performed because " & Chr(34) & "xyz" & Chr(34) & " field is blank."
2: msgbox string1
The result is:
Useful
Thanks for sharing