PC Review


Reply
Thread Tools Rate Thread

What does double quotes signify?

 
 
=?Utf-8?B?QkVFSkFZ?=
Guest
Posts: n/a
 
      18th Oct 2006
Have the following (corrected in this newsgroup)
I don't understand what the double quotes stand for, so I can't
figure out why my code does not work properly.

If Dir("C:\Contracts EMailed\" & NewName) = "" Then
I need this line to read:
If current active file name + _EM exists in C:\Contracts EMailed, Then
Call NotAllowed (which is a message with an exit statement)
Else continue.............
The context is:
Dim FName As String
FName = ActiveWorkbook.Name
Dim NewName As String
NewName = FName + "_EM"

If Dir("C:\Contracts EMailed\" & NewName) = "" Then
Call NotAllowed
Else: Exit Sub
End If
End Sub

 
Reply With Quote
 
 
 
 
David McRitchie
Guest
Posts: n/a
 
      18th Oct 2006
In your example the double quotes indicate text strings, in the
case off "" it indicates a text string with no length.

If you double the quotes within a quote it indicates a quote within

x = "he said ""I'm not working tomorrow"""

---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"BEEJAY" <(E-Mail Removed)> wrote in message news:92987BBA-DBD5-453D-B78E-(E-Mail Removed)...
> Have the following (corrected in this newsgroup)
> I don't understand what the double quotes stand for, so I can't
> figure out why my code does not work properly.
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> I need this line to read:
> If current active file name + _EM exists in C:\Contracts EMailed, Then
> Call NotAllowed (which is a message with an exit statement)
> Else continue.............
> The context is:
> Dim FName As String
> FName = ActiveWorkbook.Name
> Dim NewName As String
> NewName = FName + "_EM"
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> Call NotAllowed
> Else: Exit Sub
> End If
> End Sub
>



 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      18th Oct 2006
Double quotes indicates a string of some sort.

"" <--- Empty String
"Hello World"

The + or & symbol is the concatenate operator in the example you show. You
should really not be using the + operataor for concatenation as that is the
old standard.

--
HTH...

Jim Thomlinson


"BEEJAY" wrote:

> Have the following (corrected in this newsgroup)
> I don't understand what the double quotes stand for, so I can't
> figure out why my code does not work properly.
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> I need this line to read:
> If current active file name + _EM exists in C:\Contracts EMailed, Then
> Call NotAllowed (which is a message with an exit statement)
> Else continue.............
> The context is:
> Dim FName As String
> FName = ActiveWorkbook.Name
> Dim NewName As String
> NewName = FName + "_EM"
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> Call NotAllowed
> Else: Exit Sub
> End If
> End Sub
>

 
Reply With Quote
 
=?Utf-8?B?QkVFSkFZ?=
Guest
Posts: n/a
 
      20th Oct 2006
Gentlemen:
Thanks for the explanations and the caveats.
As always, very helpful.

"David McRitchie" wrote:

> In your example the double quotes indicate text strings, in the
> case off "" it indicates a text string with no length.
>
> If you double the quotes within a quote it indicates a quote within
>
> x = "he said ""I'm not working tomorrow"""
>
> ---
> HTH,
> David McRitchie, Microsoft MVP - Excel
> My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
> Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
>
> "BEEJAY" <(E-Mail Removed)> wrote in message news:92987BBA-DBD5-453D-B78E-(E-Mail Removed)...
> > Have the following (corrected in this newsgroup)
> > I don't understand what the double quotes stand for, so I can't
> > figure out why my code does not work properly.
> >
> > If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> > I need this line to read:
> > If current active file name + _EM exists in C:\Contracts EMailed, Then
> > Call NotAllowed (which is a message with an exit statement)
> > Else continue.............
> > The context is:
> > Dim FName As String
> > FName = ActiveWorkbook.Name
> > Dim NewName As String
> > NewName = FName + "_EM"
> >
> > If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> > Call NotAllowed
> > Else: Exit Sub
> > End If
> > End Sub
> >

>
>
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      20th Oct 2006
Just for the sake of completeness you should be aware of the difference
between "" and vbNullString when calling Windows API functions in VBA. In
most cases in VBA, you can use "" and vbNullString interchangeably. For
example,

If X = vbNullString Then
'and
If X = "" Then

will work the same way. However, there is a difference when working with
Windows API functions. Often, the documentation for an function will say
something like "Set this parameter to NULL for some action.". In this case,
you MUST use vbNullString rather than "". An "" is an allocated string in
memory that happens to have a length of 0. vbNullString indicates
unallocated memory. You can see the difference quite clearly with the
unsupported StrPtr function:

Dim S1 As String
Dim S2 As String
S1 = ""
S2 = vbNullString

If S1 = S2 Then
Debug.Print "Their values match, as expected..."
End If

Debug.Print "But their pointers don't: S1: " & CStr(StrPtr(S1)) & _
" S2: " & CStr(StrPtr(S2))



StrPtr(S1) will return some memory address.
StrPtr(S2) will return 0.

When passing null strings to Windows API functions, you MUST use
vbNullString, not "".

The unsupported StrPtr function is useful with the InputBox function. For
example in the following code, you cannot determine whether the user clicked
the OK button with no input text or clicked Cancel:

S1 = InputBox("Enter some text")
If S1 = vbNullString Then
Debug.Print "#1: User clicked Cancel OR clicked OK with no input." & _
"We can't tell the difference."
End If

However, with the StrPtr function, you can determine whether the user
clicked Cancel or clicked OK with no input text.

S1 = InputBox("Enter some text")
If StrPtr(S1) = 0 Then
Debug.Print "#2: User clicked Cancel"
Else
Debug.Print "#2: User clicked OK"
End If


This is all tangential to the original question, but it good info to have at
hand when your programming.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)




"BEEJAY" <(E-Mail Removed)> wrote in message
news:92987BBA-DBD5-453D-B78E-(E-Mail Removed)...
> Have the following (corrected in this newsgroup)
> I don't understand what the double quotes stand for, so I can't
> figure out why my code does not work properly.
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> I need this line to read:
> If current active file name + _EM exists in C:\Contracts EMailed, Then
> Call NotAllowed (which is a message with an exit statement)
> Else continue.............
> The context is:
> Dim FName As String
> FName = ActiveWorkbook.Name
> Dim NewName As String
> NewName = FName + "_EM"
>
> If Dir("C:\Contracts EMailed\" & NewName) = "" Then
> Call NotAllowed
> Else: Exit Sub
> End If
> End Sub
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting to .txt converts single quotes to double quotes Andrew P. Microsoft Excel Programming 4 27th May 2010 09:53 PM
convertng double quotes to single quotes in a column Morris Microsoft Access Form Coding 4 8th Feb 2007 04:52 PM
Replace double quotes (") with single quotes (') =?Utf-8?B?Z2Fy?= Microsoft VB .NET 7 2nd Jun 2004 02:52 PM
double-quotes single-quotes and variables Terry Microsoft Excel New Users 2 20th Apr 2004 03:08 PM
changing double quotes to open/close double quotes ken Microsoft Word New Users 5 13th Aug 2003 08:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:59 PM.