Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default What does double quotes signify?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default What does double quotes signify?

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" wrote in message ...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default What does double quotes signify?

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default What does double quotes signify?

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" wrote in message ...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default What does double quotes signify?

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
double quotes used in cell Reshma Excel Discussion (Misc queries) 1 December 19th 08 10:02 AM
Double Quotes [email protected] New Users to Excel 2 July 20th 08 12:43 PM
Double Quotes PeterM Excel Discussion (Misc queries) 5 June 17th 08 05:12 PM
Double Quotes Ed Excel Programming 1 January 13th 04 01:13 AM
Double Quotes Ed Excel Programming 1 January 12th 04 09:18 PM


All times are GMT +1. The time now is 04:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"