[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......
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.
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
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
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.
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?
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.
Re: [RESOLVED] Debugging an exe.
What is the opposite of
If MDI.ActiveForm Is Nothing Then
Edit :
If Not MDI.ActiveForm Is Nothing Then