• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

putting quotes around a string in VB Script - Windows 7

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
morinia
Asked:
morinia
1 Solution
 
5teveoCommented:
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
 
Bill PrewCommented:
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
 
MacroShadowCommented:
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

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now