Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
double quotes used in cell | Excel Discussion (Misc queries) | |||
Double Quotes | New Users to Excel | |||
Double Quotes | Excel Discussion (Misc queries) | |||
Double Quotes | Excel Programming | |||
Double Quotes | Excel Programming |