Link to home
Start Free TrialLog in
Avatar of anju_a_sagar
anju_a_sagarFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Adding Quotes to a string (")

Hi I have a code

(1)  Results = Browser("Technology Portal - Home").Page("Google Search").WebElement("results").GetROProperty("innerhtml")

---in Results variable- the value is 5800000

(2)  s_prop24="s.prop24="

-- in s_prop24 variable- the value is s.prop24=

the final result i want s.prop24="5800000"

Can you please help how can concatenate and add quotes?

thanks
anju
Avatar of solomonacquah
solomonacquah
Flag of United States of America image

enclose result with  chr(34)
Avatar of hielo
s_prop24="s.prop24=""" & Results & """
Avatar of anju_a_sagar

ASKER

hi hielo,

syntax error: unterminated string constant
there's a missing " at the end of that line. Try:

s_prop24="s.prop24=""" & Results & """"
the result is

s.prop24=""50,800,000""

i want

s.prop24="50,800,000"
Try

s_prop24="s.prop24=chr(34) & Results & chr(34)
hi,

syntax error: unterminated string constant
could you paste the code?
I have explained in my question...thats the only code

solomonacquah was very close...

Try:

    s_prop24 = "s.prop24=" & Chr(34) & Results & Chr(34)
Are you sure you are putting 4 sets of double quotes?
its coming up with

s.prop24=""50,800,000""
WHERE and HOW are you displaying your resulting string?...and are you sure that the value in Results doesn't already have quotes around it?
>>the result is
>>s.prop24=""50,800,000""
You originally said
"---in Results variable- the value is 5800000"

If that is true, then what I posted above (ID:24871542) will give you:
s.prop24="50800000"

See example below:
<script  type="text/vbscript">
Dim Results,s_prop24
 Results=5800000
s_prop24="s.prop24=""" & Results & """"
 
alert(s_prop24)
</script>
 
However, it sounds like Results does NOT equal 5800000. It sounds like 
Results equals "5800000" (with the quotes).
 
If that is the case, then you need to use:
s_prop24="s.prop24=" & Results 

Open in new window

i am using QTP tetsing tool and when i run the script i have made a check point where i can see the value of variable.

I m sure there is no quotations in Results variable value
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please see the screenshot attached.

The actual values are shown below in the variables.

but even though its shown with double quotes..its not stored with double quotes
screenshot.doc
yes u r right..in the msgbox its showing me the right value..
thanks for the help
i got it..
thanks a lot
EXACTLY...so the QTP Environment is adding the quotes around the value because it is a String variable.  The quotes are not there internally and they are only being placed there for display purposes in the test environment....  =)