home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / lang / basic / 1104 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.8 KB

  1. Path: 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
  2. From: cravitm@clvax1.cl.msu.edu (MATT CRAVIT CPS130)
  3. Newsgroups: alt.lang.basic
  4. Subject: Re: re: HELP wanted: filehandling in Visual Basic
  5. Message-ID: <1k3r46INNf49@msuinfo.cl.msu.edu>
  6. Date: 26 Jan 93 17:03:30 GMT
  7. References: <1993Jan26.135724.234@samba.oit.unc.edu>
  8. Reply-To: cravitm@clvax1.cl.msu.edu
  9. Organization: Michigan State University, East Lansing, MI
  10. Lines: 38
  11. NNTP-Posting-Host: clvax1.cl.msu.edu
  12. News-Software: VAX/VMS VNEWS 1.3-4
  13.  
  14. In article <1993Jan26.135724.234@samba.oit.unc.edu>, dil.admin@mhs.unc.edu (Dave Laudicina) writes...
  15. >>Basically, it boils down to this:
  16. >> How can I determine whether a file (in this case a .BMP) exists in the
  17. >> given path?
  18. >>
  19. >>If someone can tell me what I have to do to solve this problem, please,
  20. >>mail me. I would be very grateful.
  21. >>
  22. >You could set up a file list box for a particular drive and path 
  23. >and search through the file list to see if the file is in the list.
  24. >I would also be interested if anyone has found a more efficient way
  25. >to do this.
  26. >Thx Dave L
  27.  
  28. This is not necessarily the best way that you could use, but this should also
  29. work:
  30.  
  31. FUNCTION DoesFileExist (TheFilename$)
  32. ON LOCAL ERROR GOTO ErrorHandler
  33.  
  34. OPEN TheFilename$ FOR INPUT AS #1
  35. CLOSE #1
  36.  
  37. ErrorHandler:
  38. SELECT CASE ERR
  39.      CASE IS = (I don't remember the number, check the Error Messages appendix
  40.                 in the Reference; a certain number means file not found.)
  41.           DoesFileExist = FALSE
  42.      CASE ELSE
  43.           DoesFileExist = TRUE
  44. END SELECT
  45. END FUNCTION
  46.  
  47. I'd also like to know if anyone knows a better way to do this, because using
  48. ON LOCAL ERROR GOTO is, IMHO, a very kludgy way to program.
  49.  
  50. /Matthew
  51.