[RESOLVED] What Is Run-Time Error '5' And.......
I am trying to write a Doom game using VB6 Pro and when I load a set of Forms, using Form6.Show etc. Then at run-time I get the following message that crashes the program.
The error message is:
Run-time error '5' and the message is: invalid procedure call or argument.
Could you please debug my code to see where the error message is coming from. Becuase when I debug my code, the error doesn't come up, for some reason. Only it returns to the design screen at design-time only.
Re: What Is Run-Time Error '5' And.......
Hi,
First of all, I cannot find form6 and many other forms in your zip.
This error generally raises when you pass incompatible data type to a function parameter. It could also be due to an invalid return type. Check your form load event for the suspect code.
If the error doesn't comes up in debug mode then you might try removing the error handlers used in your code, if any.
I can help further if you give me your "form6"
Re: What Is Run-Time Error '5' And.......
Quote:
Originally Posted by mbshinde78
If the error doesn't comes up in debug mode then you might try removing the error handlers used in your code, if any.
If you notice the code doesn't use any error handling, what error handling it does have is useless and the OP has been told this more then once here, but seems to refuse to take the advise, so it's not surprising we see more posts like this one! :rolleyes:
Re: What Is Run-Time Error '5' And.......
Okay my friend here is the Form6!!
Re: What Is Run-Time Error '5' And.......
There are still several files missing (classes/modules/forms).
Even if we had those, it would take time for us to find where the error is occurring, when you should have told us at least which routine it is (and preferably the exact line too), and what steps are needed to get there.
Quote:
Originally Posted by ThEiMp
Then at run-time I get the following message that crashes the program.
It crashes because you are still not bothering to handle errors at all.
You have code that you think handles errors, but as you have been told before it is completely useless.
To prove that simply create a new project and put this code into it:
Code:
Private Sub Form_Load()
MsgBox 1 / 0
End Sub
When you run it an error will occur ("Division by zero").
Now add in what you think is error handling:
Code:
Private Sub Form_Load()
MsgBox 1 / 0
Exit Sub
OnError:
On Error GoTo 0
0 Exit Sub
Exit Sub
End Sub
When you run it, you will see that it has made no difference at all - you still get exactly the same error message and crash.
Again, to see how to actually handle errors, read the article Why do errors crash my program, and how can I stop that from happening? (making an Error Handler) from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
Re: What Is Run-Time Error '5' And.......
Okay the somewhat Error handling is removed and if you want that particular project, then please ask for it!! The error has been removed, by removing alot of junk code. But I don't understand what the error message means, do you?
Re: [RESOLVED] What Is Run-Time Error '5' And.......
Unfortunately it is a fairly generic error, and just means that you are trying to do something that isn't quite valid (but is close enough to not cause a syntax error, etc).
The help for the error includes this about the "arguments" (parameters) part of the message:
Quote:
An argument probably exceeds the range of permitted values. For example, the Sin function can only accept values within a certain range. Positive arguments less than 2,147,483,648 are accepted, while 2,147,483,648 generates this error.
Check the ranges permitted for arguments.
The "Procedure call" part of the message means that you are calling a sub/function/method when it isn't valid (like Text1.SetFocus when the form is not visible).
Without seeing the code that was involved, there isn't much more we can say.