Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.


How to Strip unwanted chars from a string by kayek
Posted: 24 Jul 03

' --------------------------------------------------
' Function StripString()
' Returns a string minus a set of specified chars.
' --------------------------------------------------
Function StripString(MyStr As Variant) As Variant
    On Error GoTo StripStringError

    Dim strChar As String, strHoldString As String
    Dim i As Integer

    ' Exit if the passed value is null.
    If IsNull(MyStr) Then Exit Function

    ' Exit if the passed value is not a string.
    If VarType(MyStr) <> 8 Then Exit Function

    ' Check each value for invalid characters.
    For i = 1 To Len(MyStr)
        strChar = Mid$(MyStr, i, 1)
        Select Case strChar
            Case ".", "#", ",", "-", " "
                  ' Do nothing
            Case Else
                strHoldString = strHoldString & strChar
        End Select
    Next i

    ' Pass back corrected string.
    StripString = strHoldString

         Exit Function

         MsgBox Error$
         Resume StripStringEnd

End Function

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close