|
-
Nov 4th, 2001, 10:39 AM
#1
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
-
Nov 4th, 2001, 10:46 AM
#2
Member
Yes, catch the error (if 5 is catchable):
VB Code:
On Error Goto SmackTheProgrammerForHavingAnError
' la de da de da...
' Error here
Exit Sub
SmackTheProgrammerForHavingAnError:
Msgbox "Hey! Why are you getting an error 5? Bad!"
-
Nov 4th, 2001, 10:47 AM
#3
Hyperactive Member
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
-
Nov 4th, 2001, 10:53 AM
#4
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.
-
Nov 4th, 2001, 12:29 PM
#5
PowerPoster
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.
-
Nov 4th, 2001, 12:32 PM
#6
Hyperactive Member
-
Nov 4th, 2001, 01:46 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|