Gonzalo,
Here find the function that you looking for.
Cheers,
-Ned
'This function will check the validity of the filename.
Public Function ValidFileName(ByVal strFileName As String) As Boolean
Dim bFound As Boolean
On Error GoTo ValidFileName_Error
ValidFileName = False 'Set default value
If Trim(strFileName) <> "" Then
'A valid filename cannot contain any of these characters /\:*?"<>
bFound = InStr(1, strFileName, "/") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, "\") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, ":") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, "*") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, "?") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, """") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, "<") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, ">") > 0
If Not bFound Then _
bFound = InStr(1, strFileName, "|") > 0
'Return validation status
ValidFileName = Not bFound
End If
Exit Function
ValidFileName_Error:
'Abort if any errors occur
End Function
Quote:
quote:Originally posted by gbianchi
hi all..
i need a function to validate the name of the file..
any pointers will be great..
thanks in advance...
Gonzalo Bianchi
|