Solved

Adding Quotes to a string (")

Posted on 2009-07-16
20
1,153 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:anju_a_sagar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 4
  • +1
20 Comments
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24870835
enclose result with  chr(34)
0
 
LVL 82

Expert Comment

by:hielo
ID: 24870927
s_prop24="s.prop24=""" & Results & """
0
 

Author Comment

by:anju_a_sagar
ID: 24871477
hi hielo,

syntax error: unterminated string constant
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 82

Expert Comment

by:hielo
ID: 24871542
there's a missing " at the end of that line. Try:

s_prop24="s.prop24=""" & Results & """"
0
 

Author Comment

by:anju_a_sagar
ID: 24871566
the result is

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

i want

s.prop24="50,800,000"
0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24871851
Try

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

Author Comment

by:anju_a_sagar
ID: 24871893
hi,

syntax error: unterminated string constant
0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24871940
could you paste the code?
0
 

Author Comment

by:anju_a_sagar
ID: 24871979
I have explained in my question...thats the only code

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24872017
solomonacquah was very close...

Try:

    s_prop24 = "s.prop24=" & Chr(34) & Results & Chr(34)
0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24872021
Are you sure you are putting 4 sets of double quotes?
0
 

Author Comment

by:anju_a_sagar
ID: 24872152
its coming up with

s.prop24=""50,800,000""
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24872168
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?
0
 
LVL 82

Expert Comment

by:hielo
ID: 24872188
>>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

0
 

Author Comment

by:anju_a_sagar
ID: 24872191
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
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24872285
I've never used QTP.  ...so you are viewing the value inside some kind of IDE?  This may be the root of the problem as it may be displaying it differently than it is actually represented internally.

How about you display the value FROM WITHIN the Script using a MsgBox?

Something like:

    s_prop24 = "s.prop24=" & Chr(34) & Results & Chr(34)
    WScript.Echo s_prop24

Does it display differently?
0
 

Author Comment

by:anju_a_sagar
ID: 24872302
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
0
 

Author Comment

by:anju_a_sagar
ID: 24872336
yes u r right..in the msgbox its showing me the right value..
thanks for the help
i got it..
0
 

Author Closing Comment

by:anju_a_sagar
ID: 31604306
thanks a lot
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24872345
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....  =)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question