Results 1 to 11 of 11

Thread: Error! ** RESOLVED**

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Thumbs up 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.

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Um, post the code that causes the error?

  3. #3

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Sorry!
    VB Code:
    1. Dim fMain As frmMain = DirectCast(Me.Owner, frmMain)
    2.         fMain.Label1.Text = lblBalance.Text
    3.         Me.Close()

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  5. #5
    Member
    Join Date
    Dec 2003
    Posts
    43
    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.

  6. #6

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    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!

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    No , try somethin like :

    VB Code:
    1. 'Class level (out side any procedure)
    2. Dim fMain As New frmMain
    3.  
    4.  
    5. 'then do this
    6.  
    7. Try
    8.             fMain = DirectCast(Me.Owner, frmMain)
    9.             fMain.Label1.Text = lblBalance.Text
    10.         Catch ex As Exception
    11.             MsgBox(Err.Description + "___" + Err.Message)
    12.         End Try
    13.         Me.Close()

  8. #8

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    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

  9. #9
    Member
    Join Date
    Dec 2003
    Posts
    43
    '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.

  10. #10

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    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!

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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
  •  



Click Here to Expand Forum to Full Width