Classic VB - Why does my program give me errors running as an Exe but not in the IDE?-VBForums
Results 1 to 1 of 1

Thread: Classic VB - Why does my program give me errors running as an Exe but not in the IDE?

  1. #1

    Thread Starter
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,116

    Classic VB - Why does my program give me errors running as an Exe but not in the IDE?

    Does your program work fine in the IDE (where you write the code), and then fail when you compile it into an Exe file? If so, one of the items below will hopefully provide you with the solution.

    Are you running code which relies on a previous piece of code, or intensive loops?
    A compiled program runs faster than code in the IDE, so it is possible that code which needs to finish its work (such as copying a file) before the next line of code starts (such as opening the same file) doesn't quite get a chance to complete when your program is compiled, even though it seems to be alright in the IDE.

    In situations like this it can be useful to let the operating system (Windows) catch-up with what it was supposed to be doing. There is a statement in VB which lets this happen, this statement is DoEvents; eg:
    VB Code:
    1. ... Code to copy the file ...
    2.   FileCopied = True
    3.  
    4.   DoEvents
    5.  
    6.   'Load the file here
    7.   Open sFileName For Input as #myFileNo
    8.   ...
    You may also find DoEvents useful inside intensive loops, as it allows the user to press keys (or the mouse) and your program can respond to them. You will also find that your forms are re-drawn at this time, which often fails to happen if your program is busy.


    Are you loading files?
    If you are loading files, how are you specifying where to load them from? If you have only specified the name of the file (and not the folder it is in) then it must be in the same folder as the application is being run from (which is likely to be the same place as the application itself).

    If you have specified a particular folder, be aware that this might not exist on other computers, so this could cause errors when installed on another computer. A good solution to this is to store files in the same folder as the application, and specify where to load them from by using code like in this thread.


    Are you running the Exe file on another computer?
    If so, did you just copy the Exe file, or did you install it properly? If you just copied it, see here for more information.
    Last edited by si_the_geek; Mar 1st, 2007 at 02:29 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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.