Object reference not set to an instance of an object.

G

Guest

I have a login screen. I enter the login info and go io the second form of my app
I push the exit button(the red X) and I'm returned to the login screen

I again enter the login info and go back to the second form of my app
I push the exit button(the red X) and that's when I get the 'Object reference not set to an instance of an object' error

I stepped throught the code and it hits the exact same code as the first go around

Why does it fails the second time around and not the first
It was working fine for one or two days and now this

Help please

Here is a little piece of code
Private Sub frmOars_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closin
Dim result As Microsoft.VisualBasic.MsgBoxResul
Dim frm1 As New frmLogi
result = MsgBox("Do you want to Quit?", MsgBoxStyle.YesNo Or MsgBoxStyle.Critical, "Quit"
If result = MsgBoxResult.Yes The
'clear memory - should be moved to the destructo
SelTeacherDataset.Dispose(
SelGradeDataset.Dispose(
SelThemeDataset.Dispose(
SelSchoolDataset.Dispose(
frm1.Show(
Me.Hide(
ElseIf result = MsgBoxResult.No The
e.Cancel = Tru
End I

End Sub
 
S

Sahil Malik

There *has* to be something remiss .. try attaching the .cs files and I can
try figuring it out.

--
- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



Joseph Burton said:
I have a login screen. I enter the login info and go io the second form of my app.
I push the exit button(the red X) and I'm returned to the login screen.

I again enter the login info and go back to the second form of my app.
I push the exit button(the red X) and that's when I get the 'Object
reference not set to an instance of an object' error.
I stepped throught the code and it hits the exact same code as the first go around.

Why does it fails the second time around and not the first?
It was working fine for one or two days and now this.

Help please!

Here is a little piece of code:
Private Sub frmOars_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?Sm9zZXBoIEJ1cnRvbg==?= said:
I have a login screen. I enter the login info and go io the second form of my app.
I push the exit button(the red X) and I'm returned to the login screen.

I again enter the login info and go back to the second form of my app.
I push the exit button(the red X) and that's when I get the 'Object reference not set to an instance of an object' error.

I stepped throught the code and it hits the exact same code as the first go around.

Why does it fails the second time around and not the first?
It was working fine for one or two days and now this.

Help please!

Here is a little piece of code:
Private Sub frmOars_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim result As Microsoft.VisualBasic.MsgBoxResult
Dim frm1 As New frmLogin
result = MsgBox("Do you want to Quit?", MsgBoxStyle.YesNo Or MsgBoxStyle.Critical, "Quit")
If result = MsgBoxResult.Yes Then
'clear memory - should be moved to the destructor
SelTeacherDataset.Dispose()
SelGradeDataset.Dispose()
SelThemeDataset.Dispose()
SelSchoolDataset.Dispose()
frm1.Show()
Me.Hide()
ElseIf result = MsgBoxResult.No Then
e.Cancel = True
End If

End Sub

On what line is the exception thrown? There can be many reasons, for
example, one of the 'Sel*' variables can be 'Nothing'.
 
G

Guest

The exception is being thrown at 'frm1.show' line

It's being done in vb.ne
Sorry, I can't send the file because it's being done for a school district.
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?Sm9zZXBoIEJ1cnRvbg==?= said:
The exception is being thrown at 'frm1.show' line.

It's being done in vb.net
Sorry, I can't send the file because it's being done for a school district.

Please post the full exception text. I assume that there is a bug in
your 'frm1''s 'Load' event handler or in another method that is called
when showing the form.
 
G

Guest

Here is the exception:

An unhandled exception of type 'System.NullReferenceException' occurred in OpSchedule.Net.exe

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top