+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: VB6.0:Tutorial, Error handling

  1. #1
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101

    Exclamation VB6.0:Tutorial, Error handling

    Introduction:-
    Ok So I decided to make a tutorial about error handling! Many programs don't contain error handling but I suggest you that you include it! This will make your program more powerful

    Solution:-
    Ok so I am going to show you this code then I will expalin it. I will show you 3 types of error handling

    What you need:-
    • 3 Command buttons
    • Some time

    Here is the code
    Code:
    Private Sub Command1_Click()
    On Error GoTo ErrorHandler
    Error 424 'This error is displayed when there is a missing object
    Exit Sub
    ErrorHandler:
    MsgBox "Error Number: " & Err.Number & " With The Description ->> " & Err.Description & " <<- Occured."
    End Sub
    
    Private Sub Command2_Click()
    On Error GoTo ErrorHandler
    Error 424
    Exit Sub
    ErrorHandler:
    If Err.Number = 424 Then
    MsgBox "A missing object in your form is needed!, Please refer to the code and arrange accordingly!"
    Else: MsgBox "Error Number: " & Err.Number & " With The Description ->> " & Err.Description & " <<- Occured."
    End If
    End Sub
    
    Private Sub Command3_Click()
    On Error Resume Next
    Error 424 'This error is displayed when there is a missing object
    MsgBox "error ignored!"
    End Sub
    Explanation:-
    Code:
    On Error GoTo ErrorHandler
    This will tell the program that when an error is found it will call the 'chunk' of code named ErrorHandler ( you will see it in a while )

    Code:
    Error 424 'This error is displayed when there is a missing object
    Exit Sub
    This will generate an error, instead of this code you will have your code here, I just made that for an error to be generated so DON'T include that in your program this is just for testing purposes!!! and the 2nd line is there so to IF no error occurs the 'chunk' of code named ErrorHandler will not be executed



    [code]
    ErrorHandler:
    MsgBox "Error Number: " & Err.Number & " With The Description ->> " & Err.Description & " <<- Occured."
    End Sub
    [code]
    This will be the action that will be done when an error occurs it will show you the error number and the description!

    Code:
    ErrorHandler:
    If Err.Number = 424 Then
    MsgBox "A missing object in your form is needed!, Please refer to the code and arrange accordingly!"
    Else: MsgBox "Error Number: " & Err.Number & " With The Description ->> " & Err.Description & " <<- Occured."
    End If
    This will be found on the Command2 event instead this type of error handling is when the programmer knows for example that when something is done the error will popup so he should make this type of error handling so not to let his program crash. here I edded IF .... THEN.... ELSE so IF the error number is 424 THEN it will do something or if not ELSE it will show the first method



    Code:
    On Error Resume Next
    Error 424 'This error is displayed when there is a missing object
    MsgBox "error ignored!"


    Here we are telling the program to just IGNORE the error and continue the next action ( in this case show a msg box )

    Conclusion:-
    As Always Feedback is welcome and the full source is attached!!
    Attached Files Attached Files
    Last edited by Jordan; 10-21-2006 at 09:03 AM. Reason: Images moved to local server

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    OMG pls Jordan can you remove this spammers post thanks!

  4. #3
    Jordan Guest
    Wow, that is the 4th one I have removed from this tutorial. They really like this one!

  5. #4
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    Lol! its my tutorial of course they like it!! lol just kidding! duh damm spammers! they are all over the net!!

  6. #5
    Join Date
    Oct 2006
    Location
    Hendersonville, NC
    Posts
    1,700
    Blog Entries
    3
    Rep Power
    0
    Suggested that we enable Image Verification on registration. I made a thread about it for the Mods/Admins to comment.


  7. #6
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    Quote Originally Posted by xXHalfSliceXx View Post
    Suggested that we enable Image Verification on registration. I made a thread about it for the Mods/Admins to comment.
    Well I sugegsted another thing in here:-
    http://forum.codecall.net/hosting-do....html#post8774
    This would definitely make it harder!!
    Last edited by TcM; 11-26-2006 at 10:26 AM.

  8. #7
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101
    Quote Originally Posted by Jordan View Post
    Wow, that is the 4th one I have removed from this tutorial. They really like this one!
    Well perhaps because it has 4 votes? as rating? I really dont know!!

  9. #8
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0
    i am hqavin a javascript error will this resolve this issue?

  10. #9
    utardylan is offline Newbie
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Thumbs down Re: VB6.0:Tutorial, Error handling

    i will take a look

  11. #10
    Join Date
    Aug 2006
    Posts
    11,209
    Blog Entries
    6
    Rep Power
    101

    Re: VB6.0:Tutorial, Error handling

    Quote Originally Posted by mathewbuer.com View Post
    i am hqavin a javascript error will this resolve this issue?
    This is a VB tutorial not a JS one.

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. Python Tutorial - Handling Command Line Arguments
    By ShadenSmith in forum Python Tutorials
    Replies: 4
    Last Post: 02-06-2011, 06:35 AM
  2. Liberty BASIC -- Error Handling
    By Irfan_A in forum Tutorials
    Replies: 0
    Last Post: 06-29-2010, 09:50 PM
  3. System.Net.WebClient error handling
    By deas in forum Visual Basic Programming
    Replies: 3
    Last Post: 03-12-2009, 01:49 PM
  4. Php error handling
    By Jaan in forum PHP Tutorials
    Replies: 3
    Last Post: 09-07-2008, 10:19 AM
  5. Error handling
    By tony.willson in forum PHP Development
    Replies: 0
    Last Post: 12-01-2007, 10:43 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts