dim xPath as string,rtn as long xPath=app.path & "fir.txt" rtn=dir(xPath)
public fuction IsFileExist(cFile as string)as long 'dim cFile as string cFile=c:\app\my.exe if dir(cFile)<>"" then IsFileExist=1 else IsFileExist=0 endif end function
cFile=c:\app\my.exe可作为参数传入.
Private Sub Form_Load() MsgBox IIf(Dir("c:\calc.exe") <> "", "存在", "不存在") End Sub '你的思路调用涵数返回的方式Private Sub Form_Load() MsgBox ChkFile("c:\calc.exe") End SubPublic Function ChkFile(Exenm$) As Long ChkFile = IIf(Dir(Exenm) <> "", 1, 0) End Function
'如果连隐藏文件也要能找到的话, 改为下面代码Private Sub Form_Load() MsgBox ChkFile("c:\calc.exe") End SubPublic Function ChkFile(Exenm$) As Long ChkFile = IIf(Dir(Exenm, vbHidden) <> "", 1, 0) End Function
xPath=app.path & "fir.txt"
rtn=dir(xPath)
'dim cFile as string
cFile=c:\app\my.exe
if dir(cFile)<>"" then
IsFileExist=1
else
IsFileExist=0
endif
end function
MsgBox IIf(Dir("c:\calc.exe") <> "", "存在", "不存在")
End Sub
'你的思路调用涵数返回的方式Private Sub Form_Load()
MsgBox ChkFile("c:\calc.exe")
End SubPublic Function ChkFile(Exenm$) As Long
ChkFile = IIf(Dir(Exenm) <> "", 1, 0)
End Function
MsgBox ChkFile("c:\calc.exe")
End SubPublic Function ChkFile(Exenm$) As Long
ChkFile = IIf(Dir(Exenm, vbHidden) <> "", 1, 0)
End Function