Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey peepz,

 

I have a sizable window, and I have a resize sub:

 

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
   lblCreated.Left = Form1.ActiveForm.ClientSize.Width - 198
End Sub

 

But when I start (F5) the app, it gives this error:

Additional information: Object reference not set to an instance of an object.

Does any of you can explain why this error is given?

 

grtz, Spyru

Posted

Hey,

 

I am not sure, but look in your initialize event of the form. I believe the form is initialized before the label. As such an instance of the label has not yet been created when the form is drawn on initialize and the resize event is fired.

 

If that is wrong, how about this: Instead of using

 

= Form1.ActiveForm.ClientSize.Width - 198

 

say

 

= Me.ClientSize.Width - 198

 

Let me know if it works...

IS

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...