dcsimg
Results 1 to 13 of 13

Thread: Runtime Error '5' for VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    8

    Runtime Error '5' for VB6

    Hi all,

    Noob here. I have noticed that on some older sytems where I run my VB6 created executables, it gives me this "Runtime Error '5': Invalid Procedure Call or Argument". This doesn't seem to be a problem on WinXP, but on some Win2000 systems I receive this. I have also run all the recent VB6 service packs.

    Anybody have any suggestions or hints?

    Thanks.

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Runtime Error '5' for VB6

    Welcome to the forums.

    Without knowing the line of code causing the error, everything will be pure speculation.

    Do you have a Win2000 machine available for your use on which you can load VB6, and run your program from the IDE to see if you can recreate the problem?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    8

    Re: Runtime Error '5' for VB6

    Ah, that's true, without knowing which line of code, it is pretty much pure speculation.

    Well the development environment for VB6 is actually on a Win2000 system as well, and unfortunately there I cannot recreate the error. I suspect that because I have VB6 installed on the development system, it must have some dlls or whatever else installed that allows for my created program to run perfectly.

    I was just hoping if someone else ran into this kind problem before and solved it -- that perhaps it is indeed some missing dll error that's available in some service pack. I just don't know which dll, if it is that issue.

  4. #4
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Runtime Error '5' for VB6

    Error code 5 is a fairly common error that can have a variety of causes.

    Is your program error trapped, or does this blow your users right back to their desktop?

    If you can't recreate it, then you can at least trap for it so they don't have to restart your program.

    Do you know if it always occurs at a specific spot or under a specific circumstance?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    8

    Re: Runtime Error '5' for VB6

    Thanks for your reply.

    I have added some extra error handlers, and for some reason the runtime error doesn't show up anymore. I'll try to understand why a little later, for now I'm just happy that it works.

    Thanks again for the suggestion!

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Runtime Error '5' for VB6

    Quote Originally Posted by pdoggeth
    Thanks for your reply.

    I have added some extra error handlers, and for some reason the runtime error doesn't show up anymore. I'll try to understand why a little later, for now I'm just happy that it works.

    Thanks again for the suggestion!
    It isn't showing up because you are trapping. If you really want to find out where it is happening, in your error trap, write the name of the routine, the error and the error description off to a file that you can later view.

    It won't tell you what line it blew up on, but at least it will tell you what sub or function it occured.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  7. #7

  8. #8
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Runtime Error '5' for VB6

    If it wasn't properly installed I'd think he would be getting a lot of errors when trying to run it, not just this one.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  9. #9
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Runtime Error '5' for VB6

    Error code 5 is 'Invalid procedure, call or argument', to find an error just use

    Err.Raise 5

    Or whatever error number you want to find

    Chris

  10. #10

  11. #11
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Re: Runtime Error '5' for VB6

    For anyone who wants to know the code for this. It for me was because of DoEvents, I had to simply add a On Error Resume Next after a DoEvents, which one, experiment, unless you know where the error is occuring.

    So it should look like:

    DoEvents
    On Error Resume Next

    Done. :P

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,028

    Re: Runtime Error '5' for VB6

    Quote Originally Posted by trak74 View Post
    For anyone who wants to know the code for this. It for me was because of DoEvents, I had to simply add a On Error Resume Next after a DoEvents, which one, experiment, unless you know where the error is occuring.

    So it should look like:

    DoEvents
    On Error Resume Next

    Done. :P
    Sorry to disagree with you but IMO that's awful advice. DoEvents can not cause a runtime error and all On Error Resume next accomplishes is to hide other errors that follow the DoEvents rather than fixing them.

  13. #13
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Runtime Error '5' for VB6

    Quote Originally Posted by MartinLiss View Post
    Sorry to disagree with you but IMO that's awful advice.
    100% agree

    DoEvents can not cause a runtime error
    Agree, with a caveat - DoEvents itself wont cause an error but the use of DoEvents within an event procedure could cause the event to be re-entered, eg if you put a DoEvents in a Winsock DataArrival event and some data was queued up for the Socket, it would re-enter the event and could, probably would, cause all sorts of mayhem, including run-time errors (best guess would be Error 13 when the second entry returns to the first) compounding the felony by using 'On Error Resume Next' would just cause even more mayhem.

    Let alone the case where the user is idly clicking buttons on the Form whilst waiting for something to complete

    (In my experience, most people write event procedures that are serially-reusable; not many write them to be fully re-entrant as well.)
    Last edited by Doogle; Jul 19th, 2011 at 01:41 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width