John,
in vb6 it was possible to write a function/sub so that a parameter of any
datatype could be declared so that it was possible to perform a check inside
the function as to whether or not a value had been specified in the calling
code.
Remember that all datatypes ultimately derive from Object, which means:
if vb.net it is no longer possible to write such a function. i this
particular area, we have gone backwards in -- a practical sense.
In VB.NET it is most certainly possible! To declare a function that accepts
"any data type" you define the parameter as Object, if you make an Object
parameter Optional, then you need to use Nothing as the default value. To
check to see if the parameter is missing you would then check
However!!! Do you write a single function that accepts a single parameter
that you then attempt to determine the parameter type of, this is what
Overloading is for, you write individual functions that accept specific
types, and find problems at compile time, instead of possible at run time.
This way if your function only accepts x, y, and z types you write three
functions that specifically accept those types, at compile time if you try
to pass w, you will get a compile error. If you want to know the parameter
was not "passed" declare an overload that does not accept a value!
*practical* is the key word here ... PRACTICAL ... ok???? a word that seems
to have escaped the vb.net architects. every day i have to write yards of
code to do what could be accomplished in much less code in vb6.
In my experience once you have the "proverbial AHA!" on OOP (overloading in
this case) then you will find that VB.NET is very practical and the VB6
method was not so practical.
Hope this helps
Jay
John A Grandy said:
there aren't any variants in vb.net
so i think that my analogy is valid
the point is the following:
in vb6 it was possible to write a function/sub so that a parameter of any
datatype could be declared so that it was possible to perform a check inside
the function as to whether or not a value had been specified in the calling
code. yes, i know we had to use variants, but the vartype function could be
applied to determine the underlining datatype. you are being unnecessarily
pedantic.
further, it was possible to specify multiple optional parameters so that in
the calling code any combination of parameters could be left out of the
arguments list, if desired.
if vb.net it is no longer possible to write such a function. i this
particular area, we have gone backwards in -- a practical sense.
*practical* is the key word here ... PRACTICAL ... ok???? a word that seems
to have escaped the vb.net architects. every day i have to write yards of
code to do what could be accomplished in much less code in vb6.
code