Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove specific characters from a string of text 1

Status
Not open for further replies.

simunjan62

Programmer
Oct 13, 2003
5
SG
The VBA experts,

I am still very weak in VBA String manulation and would like to find some help here. What happens is I have a column with numbers and alpha-numeric text in an Access Table that have certain characters I like to remove. The characters are W, R, B and K that have to be trimmed off.
Greatly appreciate any help from here.
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

No luck. I tried to edit from this code I got from somewhere before but it simple removed all the content in the column of my Table. Hope to get some help. Thank you in advance.

Code:
Public Function RemoveWnR(ByVal strCode As String) As String
    Dim intTemp As Integer
    Dim byt As Byte

    For byt = 1 To Len(strCode)
    intTemp = Asc(UCase(Mid(strCode, byt, 1)))
        If intTemp = W And R Then
            RemoveWnR = RemoveWnR & Chr(intTemp)
            Else
        End If
    Next byt
End Function
 
You may try something like this:
Code:
Public Function RemoveWnR(ByVal strCode As String) As String
    Dim strTemp As String
    Dim byt As Byte

    For byt = 1 To Len(strCode)
        strTemp = Mid(strCode, byt, 1)
        If strTemp <> "W" And strTemp <> "R" Then
            RemoveWnR = RemoveWnR & strTemp
        End If
    Next byt
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top