473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

If Typeof X IsNot Y Then...

Why doesn't the new "IsNot" operator work in conjunction with
'Typeof'?

Nov 21 '05 #1
11 5592
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
--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Jason Kendall" <Ja**********@hotmail.com> wrote in message
news:3o********************************@4ax.com...
| Why doesn't the new "IsNot" operator work in conjunction with
| 'Typeof'?
|
Nov 21 '05 #2
"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

Nov 21 '05 #3

Jay B. Harlow [MVP - Outlook] 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.


So the 'Is' in 'TypeOf X Is T' 'IsNot' the 'Is' in 'X Is Y' ? :)

--
Larry Lard
Replies to group please

Nov 21 '05 #4
Larry,
| So the 'Is' in 'TypeOf X Is T' 'IsNot' the 'Is' in 'X Is Y' ? :)

By jove I think he's got it. ;-)

--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
|
| Jay B. Harlow [MVP - Outlook] 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.
|
| So the 'Is' in 'TypeOf X Is T' 'IsNot' the 'Is' in 'X Is Y' ? :)
|
| --
| Larry Lard
| Replies to group please
|
Nov 21 '05 #5
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
Nov 21 '05 #6
Larry,

I guess it really does depend on what the meaning of the word is is!

By the way, another place that Is is used strangely in the BASIC-style
languages is its use in the Case clause of a Select Case statement, when
using relational operators. For example:

Case Is > 12

I hate the fact that Is shows up there.

Kerry Moorman

"Larry Lard" wrote:


So the 'Is' in 'TypeOf X Is T' 'IsNot' the 'Is' in 'X Is Y' ? :)

--
Larry Lard
Replies to group please

Nov 21 '05 #7
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
|
|
Nov 21 '05 #8

Jay B. Harlow [MVP - Outlook] wrote:
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...


How about

If anObject IsA Something Then

reinforcing the "is-a" idea you get in all the OO texts?

--
Larry Lard
Replies to group please

Nov 21 '05 #9
Larry,
I like IsA as a replacement for TypeOf Is!

My only concern, albeit minor, is would a quick glance of the code cause
confusion with the Is operator?

Or would one include IsA with TypeOf?

If TypeOf anObject IsA Something Then

Which would elimate the OP's question in the first place ;-)

Either way I like the IsA operator.

--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > 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...
|
| How about
|
| If anObject IsA Something Then
|
| reinforcing the "is-a" idea you get in all the OO texts?
|
| --
| Larry Lard
| Replies to group please
|
Nov 21 '05 #10
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
Or would one include IsA with TypeOf?

If TypeOf anObject IsA Something Then

Which would elimate the OP's question in the first place ;-)

Either way I like the IsA operator.


.... there must be an 'IsAn' operator too:

\\\
If Person IsAn Employee Then
...
End If
///

SCNR

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #11
Herfried,
| > Either way I like the IsA operator.
| ... there must be an 'IsAn' operator too:
*Chuckles*

I was actually thinking the same thing when I responded ;-)

--
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ep*************@TK2MSFTNGP10.phx.gbl...
| Jay,
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
| > Or would one include IsA with TypeOf?
| >
| > If TypeOf anObject IsA Something Then
| >
| > Which would elimate the OP's question in the first place ;-)
| >
| > Either way I like the IsA operator.
|
| ... there must be an 'IsAn' operator too:
|
| \\\
| If Person IsAn Employee Then
| ...
| End If
| ///
|
| SCNR
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Robert Mark Bram | last post by:
Hi All! I have the following code in an asp page whose language tag is: <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> // Find request variables. var edition = Request.Form ("edition"); var...
3
by: Alberto | last post by:
Can somebody tell me why this typeof doesn't work? foreach (Control myControl in Controls) if (typeof(myControl) == "TextBox") ((TextBox)myControl).Text = string.Empty; Thank you very much
7
by: Leon | last post by:
I have a program that fill 6 textbox on button click, but when using TypeOf my program is trying to also fill label controls which throws my array out of range. how can use TypeOf to only read...
1
by: Brien King | last post by:
Ok, I have three classes (The example here is extremely simplified to illustrate the problem) like this: Public Class A Public Sub DoSomething(ByVal myClass) If TypeOf myClass IS A Then ' '...
0
by: **Developer** | last post by:
I want to replace my If Not ...IS with If ... IsNot In the Editor ReplaceInFiles form I used this for the find If Not {.*} Is and this for the replace If \0 IsNot But that did not do it...
9
by: Klaus Johannes Rusch | last post by:
IE7 returns "unknown" instead of "undefined" when querying the type of an unknown property of an object, for example document.write(typeof window.missingproperty); Has "unknown" been defined...
4
by: EManning | last post by:
Using A2003. I've got an option group that has a number of check boxes. I have coding to clear the option group if the user wishes to cancel their choice. This coding also clears the rest of the...
20
by: effendi | last post by:
I am testting the following code in firefox function fDHTMLPopulateFields(displayValuesArray, displayOrderArray) { var i, currentElement, displayFieldID, currentChild, nDisplayValues =...
20
by: rkk | last post by:
Hi, Is there an equivalent typeof macro/method to determine the type of a variable in runtime & most importantly that works well with most known C compilers? gcc compiler supports typeof()...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.