Solved

Adding Quotes to a string (")

Posted on 2009-07-16
20
1,147 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
  • 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
Industry Leaders: 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 85

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 85

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 85

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 85

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBSScript Error IP Array 6 33
VMWare Calculate number of processors 10 94
get the ALL CAPITAL words from a cell 4 26
New Email window show up in front of any other window 3 29
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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