🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.lang.basic
Article #454

Re: re: HELP wanted: filehandling in Visual Basic

#454
From: MATT CRAVIT CPS130
Date: Tue, 26 Jan 1993 17:03
38 lines
1874 bytes
In article <1993Jan26.135724.234@samba.oit.unc.edu>, dil.admin@mhs.unc.edu (Dave Laudicina) writes...
>>Basically, it boils down to this:
>> How can I determine whether a file (in this case a .BMP) exists in the
>> given path?
>>
>>If someone can tell me what I have to do to solve this problem, please,
>>mail me. I would be very grateful.
>>
>You could set up a file list box for a particular drive and path 
>and search through the file list to see if the file is in the list.
> 
>I would also be interested if anyone has found a more efficient way
>to do this.
>Thx Dave L

This is not necessarily the best way that you could use, but this should also
work:

FUNCTION DoesFileExist (TheFilename$)
ON LOCAL ERROR GOTO ErrorHandler

OPEN TheFilename$ FOR INPUT AS #1
CLOSE #1

ErrorHandler:
SELECT CASE ERR
     CASE IS = (I don't remember the number, check the Error Messages appendix
                in the Reference; a certain number means file not found.)
          DoesFileExist = FALSE
     CASE ELSE
          DoesFileExist = TRUE
END SELECT
END FUNCTION

I'd also like to know if anyone knows a better way to do this, because using
ON LOCAL ERROR GOTO is, IMHO, a very kludgy way to program.

/Matthew
Technical Details
Message-ID: <1k3r46INNf49@msuinfo.cl.msu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!amdahl!rtech!decwrl!sdd.hp.com!cs.utexas.edu!asuvax!ukma!cs.widener.edu!dsinc!netnews.upenn.edu!msuinfo!clvax1.cl.msu.edu!cravitm
References: <1993Jan26.135724.234@samba.oit.unc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!amdahl!rtech!decwrl!sdd.hp.com!cs.utexas.edu!asuvax!ukma!cs.widener.edu!dsinc!netnews.upenn.edu!msuinfo!clvax1.cl.msu.edu!cravitm
From: cravitm@clvax1.cl.msu.edu (MATT CRAVIT CPS130)
Newsgroups: alt.lang.basic
Subject: Re: re: HELP wanted: filehandling in Visual Basic
Message-ID: <1k3r46INNf49@msuinfo.cl.msu.edu>
Date: 26 Jan 93 17:03:30 GMT
References: <1993Jan26.135724.234@samba.oit.unc.edu>
Reply-To: cravitm@clvax1.cl.msu.edu
Organization: Michigan State University, East Lansing, MI
Lines: 38
NNTP-Posting-Host: clvax1.cl.msu.edu
News-Software: VAX/VMS VNEWS 1.3-4