Solved

Vbscript string variables with single and double quotes within string

Posted on 2014-03-25
3
618 Views
Last Modified: 2014-03-25
Having trouble with single quotes and double quotes.

this is what i'm trying to put in a variable to pass in a function
Browser("Title:=.*").Page("Title:=.*").WebEdit("xpath:=//input[@name='user[username]']")

this is what I thought I had to do.
xpth = "Browser(" & """ & "Title:=.*" & """ & ").Page(" & """ & Title:=.*" & """ & ").WebEdit(" & """ & "xpath:=//input[@name=" & "'user[username]']" & """ & ")""


then on other side I would like to put in function like (xpth.exist)
0
Comment
Question by:wendellpayne
3 Comments
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
.
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

With Chr(34) it 's easier

xpth = "Browser(" & Chr(34) & "Title:=.*" & Chr(34) & ").Page(" & Chr(34) & "Title:=.*" & Chr(34) & ").WebEdit(" & Chr(34) & "xpath:=//input[@name=" & "'user[username]']" & Chr(34) & ")"

Open in new window

Regards
0
 

Author Comment

by:wendellpayne
Comment Utility
Ok I  was able to get the string into a variable and here is my code so far
tl = 30
count = 0
itsthere = false


xpth = "Browser(" & """" & "Title:=.*" & """" & ")" & ".Page(" & """" & "(Title:=.*" & """" & ").WebEdit(" & """" & "xpath:=//input[@name='user[username]']" & """" & ")"

'MsgBox(xpth)

While (count < 30 and itsthere = false)
      If (Browser("Title:=.*").Page("Title:=.*").WebEdit("xpath:=//input[@name='user[username]']").Exist) Then
         Browser("Title:=.*").Page("Title:=.*").WebEdit("xpath:=//input[@name='user[username]']").hightlight
         itsthere = true
      else
          msgbox ("Not there yet")
    End If
   wait(1)' 1 sec delay
  count = count + 1
Wend

*************************************************
Now I want to change the "IF" statement to something like this

IF (xpth.exist)

but xpth is string and not the xpath/browser object.
Any thoughts.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

771 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

12 Experts available now in Live!

Get 1:1 Help Now