Help me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • airprince
    New Member
    • Feb 2007
    • 2

    Help me

    Please help me hpow to record errors in my program and prevent my program to close if the error occurs... I want my program to go back to its starting point before it gets error.

    When the error occur, it should prompt the user that error found and save the error into the database. These also help the user to know if the transaction has been saved or not.

    Currently I am using On ERROR RESUME NEXT. In this case, the user doesnt know if the record has been saved or not.

    Please help me

    alvz
  • balid
    New Member
    • Feb 2007
    • 18

    #2
    Originally posted by airprince
    Please help me hpow to record errors in my program and prevent my program to close if the error occurs... I want my program to go back to its starting point before it gets error.

    When the error occur, it should prompt the user that error found and save the error into the database. These also help the user to know if the transaction has been saved or not.

    Currently I am using On ERROR RESUME NEXT. In this case, the user doesnt know if the record has been saved or not.

    Please help me

    alvz
    Use "ON ERROR GOTO" like this
    Code:
    Private Sub Command1_Click()
    On Error GoTo errHandle
    
       PictureBox1.Image = System.Drawing.Image.FromFile("C:\Documents and Settings\robert.lacour.RBG0\Desktop\dans vb stuff\pic\warrior.jpg")
    Exit Sub
    errHandle:
    your code here
    End Sub
    I hope that helps.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Just a caution - when doing error handling, you need to think it through carefully, to avoid pitfalls like infinite loops.

      Consider this: you hit an error, which triggers your error-handling code. Your error handler tries to save details of the error into a database, but gets an error (maybe the database file is read-only). This triggers your error-handler, which tries to record the details to the database. Which causes an error. Which triggers your error handler........ ..

      You get the idea. :)

      Comment

      Working...