dcsimg
Results 1 to 18 of 18

Thread: Works well in VB4 show run time error 53 with VB6

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Works well in VB4 show run time error 53 with VB6

    Hi, I'm trying convert an old VB4 program to VB6, and show a running error 53, please see the full code attached.
    Thanks

    Function OpenFileInputRead(tFileName$) As Integer
    OpenFileInputRead = FreeFile
    Open tFileName$ For Input Access Read As OpenFileInputRead
    End Function
    Attached Files Attached Files
    Last edited by Tony.; Feb 19th, 2018 at 10:26 AM.

  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,684

    Re: Works well in VB4 show run time error 53 with VB6

    - Rtf?
    - Wrong forum.


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Works well in VB4 show run time error 53 with VB6

    Sorry I uploaded the wrong file.
    I upload the module file now.
    Thanks

  4. #4
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,684

    Re: Works well in VB4 show run time error 53 with VB6

    It's work good for me.

    Your error:
    File not found (Error 53)
    so check the file path and/or folder

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Works well in VB4 show run time error 53 with VB6

    Hi, it work's if you just open the module, running the program stops with the 53 error.
    The program runs also with VB 5 with no error , like with VB 4,
    only happen with vb 6.
    Thanks

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,726

    Re: Works well in VB4 show run time error 53 with VB6

    The program runs also with VB 5 with no error , like with VB 4,
    on the same computer? what operating system version with the vb6? have you tried with multiple files from different folder locations?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,684

    Re: Works well in VB4 show run time error 53 with VB6

    Quote Originally Posted by Tony. View Post
    running the program stops with the 53 error.
    Program? What program???
    You haven't posted a program.
    You have posted only a BAS file.

    Excuse me, but do you know what you're doing?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: Works well in VB4 show run time error 53 with VB6

    Gibra I know I only post a bas, the one show the error, the project has a lot of bas and forms.

    Is running fine with VB 5 , so I decided use VB 5 instead VB6 for now.
    Westconn1, the OS is win7 with SP1, but also get same results with a XP SP3 (lab laptops I use)
    Thank you to all for the help.

  9. #9
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: Works well in VB4 show run time error 53 with VB6

    gibra has tried to help you with post #4.

    Error 53 is 100% definitely without fail is "File not found". So whatever the path and filename in tFileName$ is, it is pointing to a file that does not exist in the computer that you are testing on, doesn't matter whether it is VB4, 5 or 6. VB any version and Windows File System cannot be wrong.

    You can check this out yourself on the computer you are getting the error 53. Open Windows Explorer and in the address bar (see attached screen shot), enter the complete path and filename (as in tFileName$), hit enter and see what do you get. Please post back your answer, if possible show a screen shot.

    Name:  2018-02-22_134033.jpg
Views: 379
Size:  19.4 KB
    Last edited by chosk; Feb 22nd, 2018 at 01:05 AM.

  10. #10
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: Works well in VB4 show run time error 53 with VB6

    This is what I get with a file that exist in the computer. Screen shot in next post.
    Last edited by chosk; Feb 22nd, 2018 at 01:01 AM.

  11. #11
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: Works well in VB4 show run time error 53 with VB6

    This is what I get with a file that exist in the computer:
    Attached Images Attached Images  

  12. #12
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    782

    Re: Works well in VB4 show run time error 53 with VB6

    sure that image is in your private pictures samples? or it is a share from the PUBLIC docs, which in the explorer it SUMs to your account folders.

    bad english anyway

    I mean, some files which the window's explorer shows are not present in the directory of your account but in the ALL USERS account directories.

    What the explorer does is to mix two directories in the same view.

    the same does with the desktop, etc. Mis docs, etc.

  13. #13
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: Works well in VB4 show run time error 53 with VB6

    It is only an example. What OP has may not be a picture file. It so happen that I use a picture file. I could have use a txt or ini or other file type that is somewhere else in the harddisk.

    Let's try to help OP and not pick on something like this. That's why I asked OP to feed back and if preferably a screen shot so that we can see what may be the problem.

    What is important is that Windows Explorer will show whether or not that particular file exists in that particular folderpath.
    Last edited by chosk; Feb 22nd, 2018 at 04:30 AM.

  14. #14
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: Works well in VB4 show run time error 53 with VB6

    So as not to confuse or discourage OP from testing out his tFileName$ folderpath and filename, and to satisfy flyguille, here is a screen shot of what Windows Explorer will show when the file does not exist in the folderpath.
    Attached Images Attached Images   
    Last edited by chosk; Feb 22nd, 2018 at 04:56 AM.

  15. #15
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    782

    Re: Works well in VB4 show run time error 53 with VB6

    I see a problem, first, you are trying to open an image as a text file , because you wrote FOR INPUT .... that means it is sequential text input, separated by CRLF.

    if you want to open it as binary

    open filename for binary access read as filenumber

    BUT the eeror 53 is not related to that, because you can actually open any file as if it were text. Just it won't work correctly when doing LINE INPUT#1....

    when opening with binary, you needs to read filelen, so LOF(filenumber) and set an array of bytes as long as that

    example

    if lof(filenumber)>0 then
    dim b(0 to lof(filenumber)-1) as byte

    then you can do

    GET #filenumber, , b()


    and you get all the file in the array b(), in RAM in one sweep.

    then you can send it to DLLs, for image handling. and get it returned as StdPicture por example.

    if you were using SHELL to open a file, I would said, you fall in the path with spaces trap, but that seems not your case, because I don't see spaces in that path or filename.

    If you are not using ABSOLUTE path, is to say, you are using relative path, maybe you get it wrong, because unless you specify it in the FORM_LOAD, app.path <> current active directory.

    for making it right. if working with relative paths. (but not seems your case)

    in the form load , set this instruction

    ChDrive app.path
    Chdir app.path

    that will make sure that initially your current path is where the EXE is, otherwise it will be in WINDOWS/SYSTEM32 which is where the VB6 runtime DLL is.

    Other trap in modern Windows is the NTFS permits, your app must be executed with the same account which the files you are trying to acces, OR must run ELEVATED if trying to WRITE anything inside the PROGRAM FILES folders. Is to say, for writing any file inside c:\program files (x86), or c:\program files\ your app must run ELEVATED.... normally APPs can't write where the EXE is if installed inside those root directories, only installers which runs ELEVATED as administrator can create and modify directories inside that.

    IF your app don't does because it comes from old school era, is require to move all data files from PROGRAM FILES, to propper directories like "%PROGRAMDATA%\yourAppName\ " and in form_load make sure that directory exists.... so

    MakeDir "%PROGRAMDATA%\yourAppNameOrBrandName\AppName\"

    then

    Chdrive "%PROGRAMDATA%\yourAppNameOrBrandName\AppName\" (maybe a bug in this line, because I don't know if the path variable will be processed before CHDRIVE get the first character letter)
    Chdir "%PROGRAMDATA%\yourAppNameOrBrandName\AppName\"

    and your app current directory will point to that...


    then all your OPEN filename(without any path, so relative) .... will work in that folder.

    Now, setup the relative drive path is really a work around... the correct way is to work with absolute paths in all file opening.
    Last edited by flyguille; Feb 22nd, 2018 at 10:16 AM.

  16. #16
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,684

    Re: Works well in VB4 show run time error 53 with VB6

    Quote Originally Posted by Tony. View Post
    Gibra I know I only post a bas, the one show the error, the project has a lot of bas and forms.
    So how can you think that we can help you if you send only one BAS that works?
    Impossible.
    We should be wizards.

  17. #17
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,174

    Re: Works well in VB4 show run time error 53 with VB6

    >... otherwise it will be in WINDOWS/SYSTEM32 which is where the VB6 runtime DLL is.

    I don't think so. The Curdir (current directory) will reflect the folder from where the application was started. So if it is launched from a Shortcut it will be the folder specified in the Shortcut's 'Startin' property, if launched from a Cmd Command Line it will be the Cmd current folder (CD), if launched via a double click on the exe in Windows File Explorer it will reflect the folder containing the exe (App.Path).
    Last edited by Magic Ink; Feb 22nd, 2018 at 02:28 PM.

  18. #18
    Fanatic Member
    Join Date
    Dec 2014
    Posts
    896

    Re: Works well in VB4 show run time error 53 with VB6

    you can try to convert to 8.3 (shortpath) filesystem, its not just to get the 8.3 filename/path, but also to go around the unicode and too large filepath (as theres a limit here of 240? or something)

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