Private Sub Command1_Click() If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path & "\") & "T.txt") <> "" Then MsgBox "不存在文件" Else MsgBox "存在文件" End If End Sub
昏,不存在文件和存在文件写反了!修改一下吧。 Private Sub Command1_Click() If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path & "\") & "T.txt") = "" Then MsgBox "不存在文件" Else MsgBox "存在文件" End If End Sub
Dim oFSO As New Scripting.FileSystemObject If oFSO.FileExists(App.Path & "\text1.txt") Then msgbox "存在" Else msgbox "不存在" endif
if dir("c:\t.txt")<>"" then msgbox "文件存在" endif if dir(app.path & "\t.txt")<>"" then msgbox "文件存在" endif
Private Sub Command1_Click() If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path ) & "T.txt") <> "" Then MsgBox "存在文件" Else MsgBox "不存在文件" End If End Sub
If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path & "\") & "T.txt") <> "" Then
MsgBox "不存在文件"
Else
MsgBox "存在文件"
End If
End Sub
Private Sub Command1_Click()
If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path & "\") & "T.txt") = "" Then
MsgBox "不存在文件"
Else
MsgBox "存在文件"
End If
End Sub
If oFSO.FileExists(App.Path & "\text1.txt") Then
msgbox "存在"
Else
msgbox "不存在"
endif
msgbox "文件存在"
endif
if dir(app.path & "\t.txt")<>"" then
msgbox "文件存在"
endif
If Dir(IIf(Right(App.Path, 1) <> "\", App.Path & "\", App.Path ) & "T.txt") <> "" Then
MsgBox "存在文件"
Else
MsgBox "不存在文件"
End If
End Sub