|
-
Dec 21st, 2003, 01:48 AM
#1
Thread Starter
Addicted Member
Error! ** RESOLVED**
I keep on getting this error on my buddy’s Machine.
It is happening on a third Form that I’m using to enter Data into a Database.
It happens when I click the Close Button. And it only happens when using the Installed Program. If I’m running in VB it works just fine.
It is telling me: System.NullReferenceException:Object reference not set to an instance of an object.
But I don’t really know where to start looking for this error.
Can someone help?
Thanks!
Last edited by Rally2000; Dec 21st, 2003 at 04:51 PM.
-
Dec 21st, 2003, 02:39 AM
#2
Um, post the code that causes the error?
-
Dec 21st, 2003, 03:31 AM
#3
Thread Starter
Addicted Member
Sorry!
VB Code:
Dim fMain As frmMain = DirectCast(Me.Owner, frmMain)
fMain.Label1.Text = lblBalance.Text
Me.Close()
-
Dec 21st, 2003, 12:24 PM
#4
Sleep mode
Don't you have to get new instance of frmMain using 'New' Keyword and also use error handling structure around the code you suspect it cause any nasty error .
-
Dec 21st, 2003, 01:54 PM
#5
Member
No he wants a pointer to his main form i believe.
So in your mainform add this
- Frm.ActiveForm.AddOwnedForm _(Yourformthatsgoingtotkaeownershiphere)
--------------------------------------------------------------------------------
Then change this in this form to this
Dim fMain As frmMain = me.owner
fMain.Label1.Text = lblBalance.Text
Me.Close()
That should work.
-
Dec 21st, 2003, 02:21 PM
#6
Thread Starter
Addicted Member
Pirate!
I don't tink you can use the New keyword when working
I did and it is telling me the same thing!
I don't know why, but all of sudden it started replicating that error when trying to run in Debug mode, whereas before it would not.
it is stoping at
Code:
fMain.Label1.Text = lbl.Balance.Text
Also I have not yet read into error report structures.
All I know to do is use generic error code.
Code:
Try
Dim fMain As frmMain = DirectCast(Me.Owner, frmMain)
fMain.Label1.Text = lblBalance.Text
Catch ex As Exception
MsgBox(Err.Description)
End Try
Me.Close()
Thanks for any Help!
-
Dec 21st, 2003, 02:32 PM
#7
Sleep mode
No , try somethin like :
VB Code:
'Class level (out side any procedure)
Dim fMain As New frmMain
'then do this
Try
fMain = DirectCast(Me.Owner, frmMain)
fMain.Label1.Text = lblBalance.Text
Catch ex As Exception
MsgBox(Err.Description + "___" + Err.Message)
End Try
Me.Close()
-
Dec 21st, 2003, 03:40 PM
#8
Thread Starter
Addicted Member
AFterlife!
I'm missing something; my frmMain's Label needs to be updated when frmDeposit is closed. Therefore it had to have a reference to frmMain.
What is kind off funny is that it was working fine before and now it does not, I can't remember if I made any changes in my project or not. The last thing I did was to add a Module so I'm able to use a Splash Screen, but it was still working.
Anyway, when putting this " Frm.ActiveForm.AddOwnedForm _(Yourformthatsgoingtotkaeownershiphere)" in my main form it is telling me that a Declaration is expected ???
Any Idea
-
Dec 21st, 2003, 04:09 PM
#9
Member
'Put this in the area in which you want to call form 2 from
' and keep the me.ownership in the same way in your other form my bad
Dim form As New the form2 that your going to call from
MyBase.AddOwnedForm(form) ' add it as owned by frmmain
form.ShowDialog()
Last edited by AFterlife; Dec 21st, 2003 at 04:13 PM.
-
Dec 21st, 2003, 04:48 PM
#10
Thread Starter
Addicted Member
Oh my god, I feel super stupid now!
I'm calling frmDeposit from two places, one being the Menu and one being a button. What happened was this, in the Menu I have had code similar to what you posted and it is working "I checked it" but my button did not, I had added the button do to a request, and never did think about the way I hade coded my Menu. “High Inelegance here folks!” LOL
UPS!
Sometimes them little things will get ja.
Thanks guys!
PS: Pirate! that Err handler did not work, it is telling me that .Message is not a Member. But I will check into it.
Thanks!
-
Dec 21st, 2003, 10:08 PM
#11
Sleep mode
oops , it should be like this :
ex.Message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|