'------------------------------------------------------------------------------------
Public Function CheckFilename(FileName$) As Boolean
'------------------------------------------------------------------------------------
' Syfte: Kontrollera om en sträng innehåller ogiltiga tecken.
' Tar emot: En sträng
' Returnerar: En boolean
' Notering: Finns det ogiltiga tecken returneras false annars true.
Dim Valid As Boolean
CheckFilename = True
If FileName = "" Then
MsgBox "Strängen innehåller inga tecken!!", vbInformation ' Option 2
CheckFilename = False
Else
Dim I
Dim InvalidCharacters As Variant
InvalidCharacters = Split("/j{j}j[j]j
'Array("/", "{", "}", "[", "]", "<", ">", "=", "+", "~", "%", "\", "/", ";", ":", "*", "!", "@", "#", "^", "^", "?", "<", ">", "/", ",", "`", """")
For I = 0 To UBound(InvalidCharacters)
If InStr(1, FileName, InvalidCharacters(I)) Then
MsgBox "Strängen innehåller ogiltiga tecken!", vbInformation
CheckFilename = False
Exit For
End If
Next I
End If
End Function