473,847 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If Typeof X IsNot Y Then...

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

Nov 21 '05 #1
11 5627
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**********@h otmail.com> wrote in message
news:3o******** *************** *********@4ax.c om...
| 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**********@ho tmail.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*******@hotm ail.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(anObjec t) Is Something Then

Remember GetType(anObjec t) 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 SomethingSpecif ic
Inherits Something
...
End Class

Dim anObject As Object
' anObject = New Something
' anObject = New SomethingSpecif ic

If TypeOf anObject Is Something Then
' both Something & SomethingSpecif ic match
End If

If GetType(anObjec t) 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**********@h otmail.com> wrote in message
news:mb******** *************** *********@4ax.c om...
| "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**********@ho tmail.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(anObje ct, 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******** ******@tk2msftn gp13.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(anObjec t) Is Something Then
|
| Remember GetType(anObjec t) 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 SomethingSpecif ic
| Inherits Something
| ...
| End Class
|
| Dim anObject As Object
| ' anObject = New Something
| ' anObject = New SomethingSpecif ic
|
| If TypeOf anObject Is Something Then
| ' both Something & SomethingSpecif ic match
| End If
|
| If GetType(anObjec t) 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**********@h otmail.com> wrote in message
| news:mb******** *************** *********@4ax.c om...
|| "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**********@ho tmail.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(anObje ct, 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*******@hotm ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > They could have used IsTypeOf
| >
| > If IsTypeOf(anObje ct, 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

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

Similar topics

8
10024
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 language = Request.Form ("language"); Response.Write("Edition is type &quot;" + (typeof edition) + "&quot; and value &quot;" + edition + "&quot;<br>");
3
950
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
6788
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 textbox Control? Piece of Code: Dim I As Integer For I = 0 To Me.Controls.Count - 1
1
1642
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 ' ' Never Enters here.... ' End If
0
875
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 correctly Can you tell me the correct expressions?
9
10762
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 as a valid return value for the typeof operator in a later version of ECMAScript or is this a JScript "feature"? -- Klaus Johannes Rusch
4
7116
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 controls on the form. Snippet of the coding: <..snipped..> ElseIf TypeOf oCtrl Is CheckBox Then oCtrl.Value = False <..snipped..> ElseIf TypeOf oCtrl Is OptionGroup Then
20
9326
by: effendi | last post by:
I am testting the following code in firefox function fDHTMLPopulateFields(displayValuesArray, displayOrderArray) { var i, currentElement, displayFieldID, currentChild, nDisplayValues = displayValuesArray.length; for (i=0; i<nDisplayValues; i++) {
20
21798
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() macro, but the same code is not getting compiled in solaris forte compiler and in microsoft VS 2003 compiler. I tried something like below:
0
9879
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9727
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10978
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10643
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10705
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9477
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.