Results 1 to 9 of 9

Thread: type of an object

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    type of an object

    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 ?

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    would something like this work?

    If myObject.GetType Is GetType(PictureBox) Then blah
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Thumbs down

    "Object Reference not set to an instance of an object "

    It must be more complicated than this

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by pirate
    "Object Reference not set to an instance of an object "

    It must be more complicated than this
    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?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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?
    maybe I need so .anyways , I tried this but same error

    VB Code:
    1. Dim myobject As Object
    2. If myobject.GetType Is GetType(TextBox) Then
    3. MsgBox("your object is  " & myobject).ToString()
    4. End If

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by pirate
    maybe I need so .anyways , I tried this but same error

    VB Code:
    1. Dim myobject As Object
    2. If myobject.GetType Is GetType(TextBox) Then
    3. MsgBox("your object is  " & myobject).ToString()
    4. End If
    well I tried this and it worked:
    dim pic as new picturebox
    if pic.gettype() is gettype(picturebox) then msgbox "BOO"
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Well this works but return nothing without type name ??empty space what's wrong
    VB Code:
    1. Dim myobject As Object
    2. Dim txt As New TextBox()
    3. If txt.GetType Is GetType(TextBox) Then
    4. MsgBox("your object is  " & myobject).ToString()
    5. End If

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by pirate
    Well this works but return nothing without type name ??empty space what's wrong
    VB Code:
    1. Dim myobject As Object
    2. Dim txt As New TextBox()
    3. If txt.GetType Is GetType(TextBox) Then
    4. MsgBox("your object is  " & myobject).ToString()
    5. End If
    eeh I dont know what you're trying to do. What's myObject doing there?
    is this what you want?
    VB Code:
    1. Dim txt As New TextBox()
    2.         If txt.GetType Is GetType(TextBox) Then
    3.             MsgBox(txt.GetType.Name)
    4.         End If
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I forgot to delete "myobject"
    Thanx , it's working .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width