Solved

Adding Quotes to a string (")

Posted on 2009-07-16
20
1,137 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now