|
-
Apr 19th, 2007, 02:40 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Debugging an exe.
Any tips on why, when I create an executable, I get a runtime error 5 when I try to run it?
It runs in the IDE fine.
I guess it's a matter of slowly disabling procedures one by one to work out where the error is occuring but it's painful generating an exe, running it, regenerating the exe, running it......
-
Apr 19th, 2007, 02:55 PM
#2
Re: Debugging an exe.
add on error goto XXX in each sub
then msgbox the sub name so you know where the issue is
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 19th, 2007, 02:58 PM
#3
Re: Debugging an exe.
 Originally Posted by sgrya1
Any tips on why, when I create an executable, I get a runtime error 5 when I try to run it?
It runs in the IDE fine.
Without lots of extra info, no.
I guess it's a matter of slowly disabling procedures one by one to work out where the error is occuring but it's painful generating an exe, running it, regenerating the exe, running it......
Nope.. just use decent Error Handling (see the article about it in our Classic VB FAQs for explanations & examples, etc.) which includes procedure/module names, and next time you will know which procedure has the error.
If you give your code line numbers (see the MZTools link in my signature, which is a tool that does it for you - among other things!) you can also find out the precise line too.
-
Apr 19th, 2007, 03:19 PM
#4
Thread Starter
Fanatic Member
Re: Debugging an exe.
 Originally Posted by si_the_geek
Without lots of extra info, no.
I guessed that. I have lots of code though and lots of procedures. Dammed if I know what went wrong and where. Seems like a massive task to find this bug now.
10,000+ lines of code hundreds of procedures.
Most of the procedures should be disregarded I haven't touched them for a while.
Just seems like a hell of a task finding this one line.
-
Apr 19th, 2007, 03:26 PM
#5
Re: Debugging an exe.
I have had errors in much bigger projects than that, and by using error handling as described, I knew exactly where the errors occurred as soon as they happened.
-
Apr 19th, 2007, 03:28 PM
#6
Re: Debugging an exe.
Try ******* it will help you narrow down where in your code this is happening.
You should be able to find the errored line in under 1 hour.
-
Apr 19th, 2007, 03:30 PM
#7
Re: Debugging an exe.
BTW: Is this exe running on the same computer or did you copy it to another computer to run?
-
Apr 19th, 2007, 03:40 PM
#8
Thread Starter
Fanatic Member
Re: Debugging an exe.
Same computer. Really can't see what I've done.
-
Apr 19th, 2007, 03:42 PM
#9
Re: Debugging an exe.
Did you read all the posts since you last posted prior to post #8
-
Apr 19th, 2007, 03:54 PM
#10
Thread Starter
Fanatic Member
Re: Debugging an exe.
Sorry. Panicking. I'm sure I already found the general location of the error but I did as Static said and no error is reported in the procedures that follow before I pop the next msgbox. Seriously confusing.
I'm still a newbie and debugging on this one could take me days where you guys do it in minutes I'm sure.
-
Apr 19th, 2007, 04:47 PM
#11
Thread Starter
Fanatic Member
Re: Debugging an exe.
You've just taught me about how to error handle all procedures and easily do it!
I worked out that I had an "On error resume next" within one of the the error handlers so it bypassed the actual error handler procedure.
I'm not a programer but I envy your jobs. Made a wrong career path after school.
-
Apr 19th, 2007, 04:52 PM
#12
Re: Debugging an exe.
 Originally Posted by sgrya1
You've just taught me about how to error handle all procedures and easily do it!
Good stuff, you'll get lots of benefit out of that! 
I worked out that I had an "On error resume next" within one of the the error handlers so it bypassed the actual error handler procedure.
As a general rule, don't ever use "On error resume next" (see FAQs for explanation).
Typically I use it once or twice in an app (of about 100000+ lines), and then carefully!
I'm not a programer but I envy your jobs. Made a wrong career path after school.
There may well be the chance to switch.. but you might need to take a pay/status cut to do it. If it is something you really want, look into the options in your area.
-
Apr 20th, 2007, 12:33 AM
#13
Re: [RESOLVED] Debugging an exe.
Usually if you get an Runtime Error 5 in your exe and not in the IDE, you may be calling a dll that the error is generated in and you will get that message. The IDE handles that type of error by returning to the next line of code. The error does not happen in the IDE so the IDE does not know it happened and masks it.
-
Apr 20th, 2007, 12:47 AM
#14
Thread Starter
Fanatic Member
Re: [RESOLVED] Debugging an exe.
I've found the procedure now but not managed to fix it. Is a dll involved in the getsetting command? Strange that this all worked before.
The error is "Object variable or with block variable not set".
Code:
' Get Recently Opened Files from the registry using the GetAllSettings statement.
If GetSetting("MRUDemo", "MRUFileKey", "RecentFile1") = Empty Then Exit Sub
varFiles = GetAllSettings("MRUDemo", "MRUFileKey")
MDI.ActiveForm.MNUSep1.Visible = True
MDI.MNUSep1.Visible = True
For i = 0 To UBound(varFiles, 1)
MDI.ActiveForm.mnuFileMRU(i).Visible = True
MDI.mnuFileMRU(i).Visible = True
MDI.ActiveForm.mnuFileMRU(i + 1).Caption = varFiles(i, 1)
MDI.mnuFileMRU(i + 1).Caption = varFiles(i, 1)
MDI.ActiveForm.mnuFileMRU(i + 1).Visible = True
MDI.mnuFileMRU(i + 1).Visible = True
Next
Last edited by sgrya1; Apr 20th, 2007 at 12:53 AM.
-
Apr 20th, 2007, 02:06 AM
#15
Re: [RESOLVED] Debugging an exe.
Do you have option explicit at the top of all your modules, forms and classes?
What line do you get that error message on?
You also have Next but not Next i
-
Apr 20th, 2007, 02:10 AM
#16
Thread Starter
Fanatic Member
Re: [RESOLVED] Debugging an exe.
I do, yea. That was something I learn't a little while back. Wonder if there's an arguement why that isn't a default part of VB?
Not sure what line as I haven't used your *******. Will look into it after work tonight.
Thanks, added the i.
Last edited by sgrya1; Apr 20th, 2007 at 02:15 AM.
-
Apr 20th, 2007, 02:31 AM
#17
Re: [RESOLVED] Debugging an exe.
You can set it to be the default for all new forms, modules and classes.
What are the lines before that line? Is the error on that line?
-
Apr 20th, 2007, 06:47 PM
#18
Thread Starter
Fanatic Member
Re: [RESOLVED] Debugging an exe.
Not sure what happened. Whether it was restarting the computer or installing ******* but now the error is generating a msgbox in the IDE. Maybe I deleted an On Error Resume Next from somewhere that helped out.
I have an MDI form with a menu and a child form which also has it's own menu. Error is generated because I invoke the procedure GetRecentFiles() when no child form is open and therefore there is no MDI.ActiveForm.MNUSep1.Visible = True
I can fairly easily replicate this procedure for the MDI form but can I make it common to both?
Me.MNUSep1.Visible = True
Doesn't seem to work.
Thanks again for helping me find this though. I was dumbfounded before your help.
Last edited by sgrya1; Apr 20th, 2007 at 06:52 PM.
-
Apr 20th, 2007, 06:51 PM
#19
Thread Starter
Fanatic Member
Re: [RESOLVED] Debugging an exe.
What is the opposite of
If MDI.ActiveForm Is Nothing Then
Edit :
If Not MDI.ActiveForm Is Nothing Then
Last edited by sgrya1; Apr 20th, 2007 at 06:59 PM.
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
|