Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Reflection code problem

Reflection code problem

Scheduled Pinned Locked Moved Visual Basic
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amistry_petlad
    wrote on last edited by
    #1

    Hi All, I have the following code which i have type for getting the use of refection for button class, But I got following error Object reference not set to an instance of an object. Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim pobjtype As Type pobjtype = Nothing Dim PobjObject As New Object PobjObject = Nothing Dim pobjButtons As New Windows.Forms.Button() PobjObject = pobjButtons.GetType() _**For Each PobjObject In pobjtype.GetMembers** //got error here_ LstDisplay.Items.Add(PobjObject.ToString()) Next End Sub End Class Thanks in advance, amit

    G 1 Reply Last reply
    0
    • A amistry_petlad

      Hi All, I have the following code which i have type for getting the use of refection for button class, But I got following error Object reference not set to an instance of an object. Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim pobjtype As Type pobjtype = Nothing Dim PobjObject As New Object PobjObject = Nothing Dim pobjButtons As New Windows.Forms.Button() PobjObject = pobjButtons.GetType() _**For Each PobjObject In pobjtype.GetMembers** //got error here_ LstDisplay.Items.Add(PobjObject.ToString()) Next End Sub End Class Thanks in advance, amit

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You assign Nothing to the variable pobjtype, and then you try to use it as if it referenced an object. Did you assign the value to the wrong variable on the line before?

      Despite everything, the person most likely to be fooling you next is yourself.

      A 1 Reply Last reply
      0
      • G Guffa

        You assign Nothing to the variable pobjtype, and then you try to use it as if it referenced an object. Did you assign the value to the wrong variable on the line before?

        Despite everything, the person most likely to be fooling you next is yourself.

        A Offline
        A Offline
        amistry_petlad
        wrote on last edited by
        #3

        Sorry I didn't get you. Can you please explain with the line code ? Thanks

        H 1 Reply Last reply
        0
        • A amistry_petlad

          Sorry I didn't get you. Can you please explain with the line code ? Thanks

          H Offline
          H Offline
          helelark123
          wrote on last edited by
          #4

          He means that you assign Nothing to variable: pobjtype = Nothing and then you try to use it for ... in pobjtype.GetMembers

          Shay Noy

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups