Doh!
| If TypeOf(anObject, Something) Then
|
| IMHO However that doesn't read as well.
They could have used IsTypeOf
If IsTypeOf(anObject, Something) Then
Although it reads better then the above, I still prefer the TypeOf operator
as is...
--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:u6**************@tk2msftngp13.phx.gbl...
| Jason,
|| How very strange. That clears up why 'TypeOf' doesn't use
|| parenthesis.
| Yea its strange, I think parenthesis would "complicate" the TypeOf syntax
| unnecessarily as:
|
| If TypeOf(anObject) Is Something Then
|
| Is miss-leading, it too close to GetType. TypeOf "IsNot" GetType!
|
| If TypeOf anObject Is Something Then
|
| is different then:
|
| If GetType(anObject) Is Something Then
|
| Remember GetType(anObject) returns a specific type & checks to see if o is
| specifically Something, where as TypeOf allows derived types & interfaces
to
| also match. For example:
|
| Class Something
| ...
| End Class
|
| Class SomethingSpecific
| Inherits Something
| ...
| End Class
|
| Dim anObject As Object
| ' anObject = New Something
| ' anObject = New SomethingSpecific
|
| If TypeOf anObject Is Something Then
| ' both Something & SomethingSpecific match
| End If
|
| If GetType(anObject) Is Something Then
| ' only Something matches
| End If
|
| I suppose they could have implemented TypeOf as a function similar to
CType
| & DirectCast:
|
| If TypeOf(anObject, Something) Then
|
| IMHO However that doesn't read as well.
|
| --
| Jay [MVP - Outlook]
| .NET Application Architect, Enthusiast, & Evangelist
| T.S. Bradley -
http://www.tsbradley.net
|
|
| "Jason Kendall" <Ja**********@hotmail.com> wrote in message
| news:mb********************************@4ax.com...
|| "The "Is" in the TypeOf operator is a placeholder"
||
|| How very strange. That clears up why 'TypeOf' doesn't use
|| parenthesis.
||
|| Thanks.
||
|| --
|| Jason Kendall
||
Ja**********@hotmail.com
||
||
||
|| On Fri, 21 Oct 2005 10:33:08 -0500, "Jay B. Harlow [MVP - Outlook]"
|| <Ja************@tsbradley.net> wrote:
||
|| >Jason,
|| >IMHO:
|| >
|| >Because IsNot is the inverse of the Is operator. They are both used to
|| >compare object references.
|| >
|| >
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
|| >
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
|| >
|| >The "Is" in the TypeOf operator is a placeholder & not the operator per
| se.
|| >The TypeOf operator is used to check the data type of an object
| reference.
|| >
|| >
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
|
|