Hi I am getting an error when I load my program from the exe file but not when I start from visual studio.
The error I receive is
>System.NullReferenceException: Object reference not set to an instance of an object.
at MoveResizeControl.controlHandler.mControl_Resize(Object sender, EventArgs e) in C:\\Users\\AJ\\Documents\\Movable_Re217400212010\\MoveResizeControl\\controlHandler.vb:line 211
at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
at System.Windows.Forms.Control.UpdateBounds() at System.Windows.Forms.Control.WmWindowPosChanged(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.GroupBox.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam
I know my problem is in this bit of code
Private Sub Timer7_Tick(sender As Object, e As EventArgs) Handles Timer7.Tick
Timer2.Start()
Timer5.Start()
Dim i As Integer
i = 0
Dim bl1 As Integer
Dim br1 As Integer
Dim tl1 As Integer
Dim tr1 As Integer
Dim bl14 As Integer
Dim br14 As Integer
Dim tl14 As Integer
Dim tr14 As Integer
bl1 = bl.Text
br1 = br.Text
tl1 = tl.Text
tr1 = tr.Text
bl14 = bl4.Text
br14 = br4.Text
tl14 = tl4.Text
tr14 = tr4.Text
Me.PictureBox1.Height = (i + bl1) - (i + tl1)
Me.PictureBox1.Width = (i + br1) - (i + tr1)
Me.GroupBox1.Height = (i + bl14) - (i + tl14)
Me.GroupBox1.Width = (i + br14) - (i + tr14)
Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X + (0 + tr.Text), Me.PictureBox1.Location.Y + (0 + tl.Text))
Me.GroupBox1.Location = New Point(Me.GroupBox1.Location.X + (0 + tr4.Text), Me.GroupBox1.Location.Y + (0 + tl4.Text))
Timer7.Stop()
End Sub
I need to check for null before commencing and am having a problem.
It's possible that the timer tick event is executed before initialization is complete. Try leaving the timers disabled, then enable them in the form "shown" event.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.