A reason to like Microsoft

  • Thread starter Thread starter John A. Bailo
  • Start date Start date
J

John A. Bailo

Say what you will.

I have to appreciate a language where you can do this:


object objMissing = System.Reflection.Missing.Value;
 
John said:
Say what you will.

I have to appreciate a language where you can do this:


object objMissing = System.Reflection.Missing.Value;

Why? How is that useful?
 
Tom said:
Why? How is that useful?

This way, I have a general purpose /placeholder/ for values in methods
that I would never use. For example,

object FileOpen = (object) @"\Test.doc";

Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.DocumentClass();

oDoc = wordApp.Documents.Open(ref FileOpen,
ref objMissing, ref objMissing,ref objMissing,ref objMissing,
ref objMissing, ref objMissing,ref objMissing,ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing);
 
John said:
This way, I have a general purpose /placeholder/ for values in methods
that I would never use. For example,

object FileOpen = (object) @"\Test.doc";

Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.DocumentClass();

oDoc = wordApp.Documents.Open(ref FileOpen,
ref objMissing, ref objMissing,ref objMissing,ref objMissing,
ref objMissing, ref objMissing,ref objMissing,ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing);

Still seems pointless - and actually less clear. I would prefer to use
it this way:

oDoc = wordApp.Documents.Open (ref fileOpen, ref Missing.Value, ref
Missing.Value,....

You get the picture. Slightly more typing, but to mind clearer.
 
I appreciate a language where you can do this:

Module Module1
Sub Main()
Dim FileOpen As String = "C:\Temp\Test.doc"
Dim oWord As New Word.Application
Dim oDoc As Word.Document = _
oWord.Documents.Open(FileOpen)
End Sub
End Module
 
This is a perfect example of picking the right tool for the job. It's a
no-brainer to use VB when programming Office applications.
 
Don't you have the option to use named parameters? That way you know exactly
what you're passing and by inference, what it is for, as well as not having
to worry about someone changing the method's signature?

-Eric
 
Back
Top