Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding Quotes to a string (")

Posted on 2009-07-16
20
Medium Priority
?
1,157 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
Independent Software Vendors: 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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