Thread View: alt.lang.basic
5 messages
5 total messages
Started by Dave Laudicina
Tue, 26 Jan 1993 13:57
re: HELP wanted: filehandling in Visual Basic
Author: Dave Laudicina
Date: Tue, 26 Jan 1993 13:57
Date: Tue, 26 Jan 1993 13:57
13 lines
908 bytes
908 bytes
>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
Re: re: HELP wanted: filehandling in Visual Basic
Author: MATT CRAVIT CPS130
Date: Tue, 26 Jan 1993 17:03
Date: Tue, 26 Jan 1993 17:03
38 lines
1874 bytes
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
Re: HELP wanted: filehandling in Visual Basic
Author: Brian Wheeler
Date: Tue, 26 Jan 1993 17:53
Date: Tue, 26 Jan 1993 17:53
40 lines
1819 bytes
1819 bytes
In <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 the Dir$ function Returns the name of a file matching a filespec. if the filespec is a filename without wildcards, it returns whether or not the file exists. Here's what I do: const False = 0 Const True = Not False Function Exists(Filespec$) if Dir$(FileSpec$) <> "" then Exists = True Exit Function else Exists = False end if End Function Brian Wheeler -- ****************************************************************************** * Brian 'Nautical' Wheeler - These are my opinions, do you hear me? MINE! * cat flames > /dev/null "Wombats are our friends" - Me ******************************************************************************
Re: HELP wanted: filehandling in Visual Basic
Author: Barry Bond
Date: Tue, 26 Jan 1993 19:53
Date: Tue, 26 Jan 1993 19:53
25 lines
1274 bytes
1274 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
>
>
It's easier to use DIR$() to check if a file exists: eg.
if Dir$("c:\vb\test.bmp") <> "" then
debug.print "File exists"
else
debug.print "File not found"
endif
Barry.
Re: HELP wanted: filehandling in Visual Basic
Author: Bruce Garrett
Date: Wed, 27 Jan 1993 23:45
Date: Wed, 27 Jan 1993 23:45
32 lines
1525 bytes
1525 bytes
dil.admin@mhs.unc.edu (Dave Laudicina) writes:
>> > 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.
DL> You could set up a file list box for a particular drive and path
DL> and search through the file list to see if the file is in the list.
DL> I would also be interested if anyone has found a more efficient way
DL> to do this.
Why can't you use the DIR$ Function? This function accepts a
filespec mask and returns a string containing a filename or NULL if the file
does not exist and can be repeatedly polled for all files meeting a wildcard
filespec.
IF Len(Dir$(FileSpec$)) > 0 THEN
(stuff to do if the file exists)
ELSE
(stuff to do if it ain't there)
END IF
Check out page 94 of the Language Reference.
-Bruce Garrett
\
--- IF Bogosity%(Opinion$) > BSThreshold% THEN Opinion$ = "" /\
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads