filexist.bas

来自「又一个将HTML文件转换成文本文件的程序」· BAS 代码 · 共 37 行

BAS
37
字号
Option Explicit

Function FileExists% (filename$)

' Description
'     Checks 'filename$' to find wether the filename given
'     exists.
'
' Parameters
'     Name              Type     Value
'     -------------------------------------------------------------
'     filename$         String   The filename to be checked
'
' Returns
'     True if the file exists
'     False if the file does not exist
'
' Last updated by Jens Balchen 21.11.95


Dim f%

   ' Trap any errors that may occur
   On Error Resume Next

   ' Get a free file handle to avoid using a file handle already in use
   f% = FreeFile
   ' Open the file for reading
   Open filename$ For Input As #f%
   ' Close it
   Close #f%
   ' If there was an error, Err will be <> 0. In that case, we return False
   FileExists% = Not (Err <> 0)

End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?