Results 1 to 7 of 7

Thread: Errors

  1. #1
    Hellstorm
    Guest

    Angry Errors

    When i run one of my programs i get a runtime error 5 i know what this error means but the user wouldnt is there a way i can change this from a runtime error to a popup msg that describes why this error has occoured

    Thanx for any help you guys are great

  2. #2
    Yes, catch the error (if 5 is catchable):
    VB Code:
    1. On Error Goto SmackTheProgrammerForHavingAnError
    2.  
    3. ' la de da de da...
    4. ' Error here
    5.  
    6. Exit Sub
    7.  
    8. SmackTheProgrammerForHavingAnError:
    9.     Msgbox "Hey! Why are you getting an error 5? Bad!"

  3. #3
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    I always use this to display an error.

    If err.number>0 then
    Msgbox "Err #" & err.number ":" & vbCrLf & err.description., vbExclamation, "Error!"
    end if

    But I'm not sure if this is what you meant. If you mean that you want to give them the reason of the error, then be prepared to do a whole lot of work.

    you'll have to know all errors and their reasons from your program, create a database with them and messages that explain why it went wrong. If the error occurs you'll just have to read out the message from the database and display it. This is much work just to display a right error, which most users won't understand either, so I only use it in case that I'm building a big program. It's not worth the time for small programs
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  4. #4
    Hellstorm
    Guest
    Thanx for all the help but i still dont quite understand. Ill explain a little more what im trying to do.

    I have a program that when i click a button it will insert text using the SendKeys command in to a window, I have a text box for the user to input the name of the window but if they forget to type the name or they spelt it incorrectly i get a runtime error 5 i would like to inform them that they need to re enter the name of the window when this error appears.


    Please explain in a little more detail of how i can do this.

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Code:
    Private Sub Command1_Click()
        On Error GoTo ErrorHandler
        AppActivate "Notepad", True
        SendKeys "Hello"
        
        Exit Sub
    ErrorHandler:
        If Err.Number = 5 Then
            MsgBox "Please check that your fields are correct.", vbInformation + vbOKOnly, "Missing Data"
        Else
            MsgBox Err.Number, Err.Description, Err.Source
        End If
        Err.Clear
    End Sub
    Last edited by Lethal; Nov 4th, 2001 at 12:38 PM.

  6. #6
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    yep, that should do it.
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  7. #7
    Hellstorm
    Guest
    Thankyou all so much thats just what i needed

    You have made me very happy

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