0

I am not sure how to set an object reference to frmD.Picture1.ClientRectangle?? I am using win7 and vb.net 2008

frmD.Picture1.ClientRectangle=new frmD.Picture1.ClientRectangle???             

            'error object reference not set ....
            xpos = frmD.Picture1.ClientRectangle.Left
            ypos = frmD.Picture1.ClientRectangle.Top
2
  • What exactly are you trying to do with the xpos, and ypos? Commented Nov 11, 2012 at 4:22
  • You need to instantiate the object before you can reference it. IE something has never been made new or set to something. Commented Nov 11, 2012 at 4:48

1 Answer 1

3

Object reference not set to an instance of an object means that you're trying to access some member of an uninstantiated object. What that means is that you forgot to create the object (via new).

In your case, you're probably trying to use frmD or Picture1 before it has been created.

Sign up to request clarification or add additional context in comments.

4 Comments

I updated my question, I believe I am missing something within frmD.Picture1.ClientRectangle=new frmD.Picture1.ClientRectangle
No, you shouldn't be doing it like that, ClientRectangle is supposed to be provided by the PictureBoxControl (or whatever it is you're using). Is there a chance you're calling this code before the form is loaded?
No, because I am loading the form first with the following statement Dim frmD As New frmMain and other processes are performed before where my issue occurs.
This "Dim frmD As New frmMain" doesn't load the form it simply instatitates it. You need a Show or ShowDialog to Load the form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.