t As Boolean
   For i = 1 To Len(sString)
      sC = Mid(sString, i, 1)
      Select Case sC
      Case "\", "/", ":", "?", "*", "&lt;", "&gt;", "|"
         sRet = sRet &amp; "_"
         bLastCharDot = False
      Case "."
         If (bLastCharDot) Then
            ' skip it
         Else
            bLastCharDot = True
            sRet = sRet &amp; "."
         End If
      Case Else
         If (Asc(sC) &lt; 32) Then
            sRet = sRet &amp; "_"
         Else
            sRet = sRet &amp; sC
     