|
See if File already exists!
Option Explicit
Public Function FileExist(asPath As String) As Boolean
'
'Checks for an existing File,
'returns True or False
'examples:
'If FindFile(Text1.Text) Then Label1 = "YES"
'If Not FindFile(Text1.Text) Then Label1 = "NO"
If UCase(Dir(asPath)) = UCase(TrimPath(asPath)) Then
FileExist = True
Else
FileExist = False
End If
End Function
Public Function TrimPath(ByVal asPath As String) As String
If Len(asPath) = 0 Then Exit Function
Dim x As Integer
Do
x = InStr(asPath, "\")
If x = 0 Then Exit Do
asPath = Right(asPath, Len(asPath) - x)
Loop
TrimPath = asPath
End Function
Private Sub Command1_Click()
If FileExist(Text1.Text) Then
Label1 = "YES"
Else
Label1 = "NO"
End If
End Sub
--------------------------------------------
Original tip and project submitted by
Bill Custer.
--------------------------------------------
|
Quick searches: Site Search | Advanced Site Search |
|
By using this site you agree to its terms and conditions VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc. |