Solved

putting quotes around a string in VB Script  -  Windows 7

Posted on 2014-03-04
3
304 Views
Last Modified: 2014-03-04
Experts,

I have a string that has the address of a directory.  I just built this string and now I want to see if it exists.  How do I add quotation marks around the directory?

Currently string  myDir has the value below in it.



myDir= \\Main\FolderA\FolderB\FolderC\FolderD

I need  "\\Main\FolderA\FolderB\FolderC\FolderD"  to test the presence of the folder
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:5teveo
ID: 39904467
Try

myDir= '"\\Main\FolderA\FolderB\FolderC\FolderD"' <--singles quotes on outside of string

myDir= ""\\Main\FolderA\FolderB\FolderC\FolderD"" <--2 double quotes on outside of string

myDir= """\\Main\FolderA\FolderB\FolderC\FolderD""" <--3 double quotes on outside of string
0
 
LVL 55

Accepted Solution

by:
Bill Prew earned 300 total points
ID: 39904530
I use a small function for this, as shown below:

myDir = Quote("\\Main\FolderA\FolderB\FolderC\FolderD")

' Small routine to add double quotes around a string
Function Quote(strText)
   Quote = Chr(34) & strText & Chr(34)
End Function

Open in new window

~bp
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39904563
You don't need quotation marks if myDir is a string variable, just pass myDir to your function that tests the path.
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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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