Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding Quotes to a string (")

Posted on 2009-07-16
20
Medium Priority
?
1,159 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

783 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