Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

belongs to class (how to check)

In my coursework program I have a parent class called tenant. I have 3 iheriting from it classes. They are Student, Teacher, and Guest.
I have a listbox with all the tenants. and I would like to put 3 chechboxes into the form: Students, Teachers, Guests. If a checkbox for the class is selected the objects of this class will stay in the listbox, while objects of the class that has an unchecked checkbox will not appear in the listbox.

What is the easiest way to check if an object belongs to some class or not?
I might use an if statement like this:

If tenant1 [is an instance of Students] Then
lstbox.Items.Add(tenant1)
ENd If

But what should I write instead of [is an instance of Students]?
Thank you. :)
[757 byte] By [ice-deloff] at [2007-11-11 8:28:34]
# 1 Re: belongs to class (how to check)
If TypeOf tenant1 Is Student Then
Phil Weber at 2007-11-11 21:47:23 >