' Collection of code snippets by Arne VajhÃ¸j 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Function Sanitize(s As String) As String
    Dim res As String
    Dim i As Integer
    Dim c As Integer
    res = s
    For i = 1 To Len(res)
        c = Asc(Mid(res, i, 1))
        If ((c >= 32) And (c <= 126)) Or (InStr("Ã?Ã?Ã?Ã¦Ã¸Ã¥", Chr(c)) > 0) Then
            ' leave as is
        Else
            Mid(res, i, 1) = "_"
        End If
    Next i
    Sanitize = res
End Function

Function test()
    MsgBox Sanitize("ABC123Ã?Ã?Ã?")
End Function
