How can I know the data type of an object in general ? I tried GetType but with no luck !
as an example
system.Activator (there are million of objects ....)
thanx for any help ?
Printable View
How can I know the data type of an object in general ? I tried GetType but with no luck !
as an example
system.Activator (there are million of objects ....)
thanx for any help ?
would something like this work?
If myObject.GetType Is GetType(PictureBox) Then blah
"Object Reference not set to an instance of an object "
:p
It must be more complicated than this
well then set it to something! :)Quote:
Originally posted by pirate
"Object Reference not set to an instance of an object "
:p
It must be more complicated than this
yeah you're right, you cant' check the object type with GetType if it's set to Nothing.... but would you really wanna check an object type if it's null? :rolleyes:
maybe I need so .anyways , I tried this but same errorQuote:
Originally posted by MrPolite
well then set it to something! :)
yeah you're right, you cant' check the object type with GetType if it's set to Nothing.... but would you really wanna check an object type if it's null? :rolleyes:
VB Code:
Dim myobject As Object If myobject.GetType Is GetType(TextBox) Then MsgBox("your object is " & myobject).ToString() End If
well I tried this and it worked:Quote:
Originally posted by pirate
maybe I need so .anyways , I tried this but same error
VB Code:
Dim myobject As Object If myobject.GetType Is GetType(TextBox) Then MsgBox("your object is " & myobject).ToString() End If
dim pic as new picturebox
if pic.gettype() is gettype(picturebox) then msgbox "BOO"
Well this works but return nothing without type name ??empty space:confused: what's wrong
VB Code:
Dim myobject As Object Dim txt As New TextBox() If txt.GetType Is GetType(TextBox) Then MsgBox("your object is " & myobject).ToString() End If
eeh I dont know what you're trying to do. What's myObject doing there?Quote:
Originally posted by pirate
Well this works but return nothing without type name ??empty space:confused: what's wrong
VB Code:
Dim myobject As Object Dim txt As New TextBox() If txt.GetType Is GetType(TextBox) Then MsgBox("your object is " & myobject).ToString() End If
is this what you want?VB Code:
Dim txt As New TextBox() If txt.GetType Is GetType(TextBox) Then MsgBox(txt.GetType.Name) End If
I forgot to delete "myobject"
Thanx , it's working . :D