Very basic question: How to store " in strings? 
Author Message
 Very basic question: How to store " in strings?

Hi,
I'm trying to write a windows script using VBS to create 50 shortcuts. This
is the first time I'm doing any VBS and I'm stumped by so many of its
idiosyncrasies. All I want to do is store a " inside a string for the
shortcut paths. For example, I want to store this string in a variable:

"C:\Msaccess.exe" /WKGRP "C:\ABC.MDB"

I tried escaping the quotes using backslash, like in other languages, but
that does not seem to work in VBS. Please help!
amit



Mon, 28 Nov 2005 20:51:26 GMT  
 Very basic question: How to store " in strings?
Double the quote, concatenate Chr(34), or use a safe character in place of
the " and replace after.

sVar = """C:\Msaccess.exe"" /WKGRP ""C:\ABC.MDB"""
or
sVar = Chr(34) & "C:\Msaccess.exe" & Chr(34) & " /WKGRP " & Chr(34) &
"C:\ABC.MDB" & Chr(34)
or
sVar = "|C:\Msaccess.exe| /WKGRP |C:\ABC.MDB|"
sVar = Replace(sVar, "|", """")

Ray at work


Quote:
> Hi,
> I'm trying to write a windows script using VBS to create 50 shortcuts.
This
> is the first time I'm doing any VBS and I'm stumped by so many of its
> idiosyncrasies. All I want to do is store a " inside a string for the
> shortcut paths. For example, I want to store this string in a variable:

> "C:\Msaccess.exe" /WKGRP "C:\ABC.MDB"

> I tried escaping the quotes using backslash, like in other languages, but
> that does not seem to work in VBS. Please help!
> amit



Mon, 28 Nov 2005 21:18:54 GMT  
 Very basic question: How to store " in strings?
In vbs, you double the character to escape it:

str= """C:\Msaccess.exe"" /WKGRP ""C:\ABC.MDB"""

Quote:

> Hi,
> I'm trying to write a windows script using VBS to create 50
> shortcuts. This is the first time I'm doing any VBS and I'm stumped
> by so many of its idiosyncrasies. All I want to do is store a "
> inside a string for the shortcut paths. For example, I want to store
> this string in a variable:

> "C:\Msaccess.exe" /WKGRP "C:\ABC.MDB"

> I tried escaping the quotes using backslash, like in other languages,
> but that does not seem to work in VBS. Please help!
> amit



Mon, 28 Nov 2005 21:20:27 GMT  
 Very basic question: How to store " in strings?
Amit,

Since you mention creation of shortcuts, I add to what Ray
and Bob have already pointed out to say that you also need
to understand that the Target property is just that: the
pathspec to the target executable ONLY.  Do not try to put
arguments (command switches, filenames, etc.) into the
Target.  Instead, place these into the Arguments property
provided for that use.

Hope this saves you from a few moments (hours?!) of
confusion and frustration.  It surely slowed me down a
while when I was getting started.

Tom Lavedas
===========

Quote:
>-----Original Message-----
>Hi,
>I'm trying to write a windows script using VBS to create
50 shortcuts. This
>is the first time I'm doing any VBS and I'm stumped by so
many of its
>idiosyncrasies. All I want to do is store a " inside a
string for the
>shortcut paths. For example, I want to store this string
in a variable:

>"C:\Msaccess.exe" /WKGRP "C:\ABC.MDB"

>I tried escaping the quotes using backslash, like in

other languages, but
Quote:
>that does not seem to work in VBS. Please help!
>amit

>.



Mon, 28 Nov 2005 22:19:47 GMT  
 Very basic question: How to store " in strings?
That's exactly the problem I'm running into! Thanks a bunch for that
clarification, Tom
amit


Quote:
> Amit,

> Since you mention creation of shortcuts, I add to what Ray
> and Bob have already pointed out to say that you also need
> to understand that the Target property is just that: the
> pathspec to the target executable ONLY.  Do not try to put
> arguments (command switches, filenames, etc.) into the
> Target.  Instead, place these into the Arguments property
> provided for that use.

> Hope this saves you from a few moments (hours?!) of
> confusion and frustration.  It surely slowed me down a
> while when I was getting started.

> Tom Lavedas
> ===========

> >-----Original Message-----
> >Hi,
> >I'm trying to write a windows script using VBS to create
> 50 shortcuts. This
> >is the first time I'm doing any VBS and I'm stumped by so
> many of its
> >idiosyncrasies. All I want to do is store a " inside a
> string for the
> >shortcut paths. For example, I want to store this string
> in a variable:

> >"C:\Msaccess.exe" /WKGRP "C:\ABC.MDB"

> >I tried escaping the quotes using backslash, like in
> other languages, but
> >that does not seem to work in VBS. Please help!
> >amit

> >.



Mon, 28 Nov 2005 23:10:57 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. String "justification" question

2. Incredibly "basic" Question

3. Incredibly "basic" Question

4. "Is Visual BASIC basic?"

5. How to store / retrieve a stored (hidden) value from a combo box in Visual Basic 6

6. A V.Basic SQL String Question

7. Basic question on find a character in a string

8. A Question About Characters and Strings In Visual Basic

9. store Attachments in "ACCESS"

10. how to convert numeric string "50,345.00" to string "50345"

11. Help with "COUNT" in stored procedure

12. Making Stored Proc Resultset "Editable"

 

 
Powered by phpBB® Forum Software