UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> ToFileName    

' ToFileName
' http://www.utteraccess.com/wiki/index.php/FunctionNameHere
' Code courtesy of UtterAccess Wiki
' Original submission by Diego F.Pereira-Perdomo
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2012-07-10                    Removes non-alphanumeric characters of a string. Useful for file names.
Public Function ToFileName(strChar As String)

On Error GoTo ErrorHandler

Dim l       As Integer
Dim i       As Integer
Dim Char    As String
Dim strAN   As String
Dim strStr  As String

strAN = "0123456789abcdefghijklmnopqrstuvwxyz"

l = Len(strChar)

For i = 1 To l
   Char = Mid(strChar, i, 1)
   If InStr(strAN, Char) Then
       strStr = strStr & Char
   End If
Next i

ToFileName = strStr

Select Case Err.Number
   Case 0
   Case Else
       MsgBox Err.Number & ": " & Err.Description
End Select
End Function

Creative Commons License
ToFileName by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 2,564 times.  This page was last modified 06:50, 10 July 2012 by dipetete.   Disclaimers