C
Craig
In an earlier post, I said that I wanted to eliminate
funky characters (i.e. /, \, }, {, *, #, etc.) from part
numbers, thereby turning N-11#4 into N114. I want to be
able to specify which characters I am going to eliminate.
These could include characters or substrings, like
demonstrated below.
I have gotten code that will do that, but not specifically
what I need it to do....i need something that is really
like a replace function, but I am using Access 97.
in addition to the funky characters listed above, i need
to do the following...
turn: N-11(OLD)
into: N11
turn: 12-34#5(FINE)
into: 12345
turn: 1 2 345(NEW)
into: 12345
the code i have is the following, but does not account for
the (NEW), (OLD), (FINE) stuff. can anyone help?
Function Cleanse(ByVal InString As String) As String
Dim StringLength As Long
Dim OutString As String
Dim i As Long
Dim TempString As String
StringLength = Len(InString)
OutString = ""
For i = 1 To StringLength
TempString = Left$(InString, 1)
InString = Right$(InString, StringLength - i)
If (Asc(TempString) >= 65 And Asc(TempString) <= 90) Or _
(Asc(TempString) >= 97 And Asc(TempString) <= 122) Or _
(Asc(TempString) >= 48 And Asc(TempString) <= 57) Then
OutString = OutString & TempString
End If
Next i
Cleanse = OutString
End Function
funky characters (i.e. /, \, }, {, *, #, etc.) from part
numbers, thereby turning N-11#4 into N114. I want to be
able to specify which characters I am going to eliminate.
These could include characters or substrings, like
demonstrated below.
I have gotten code that will do that, but not specifically
what I need it to do....i need something that is really
like a replace function, but I am using Access 97.
in addition to the funky characters listed above, i need
to do the following...
turn: N-11(OLD)
into: N11
turn: 12-34#5(FINE)
into: 12345
turn: 1 2 345(NEW)
into: 12345
the code i have is the following, but does not account for
the (NEW), (OLD), (FINE) stuff. can anyone help?
Function Cleanse(ByVal InString As String) As String
Dim StringLength As Long
Dim OutString As String
Dim i As Long
Dim TempString As String
StringLength = Len(InString)
OutString = ""
For i = 1 To StringLength
TempString = Left$(InString, 1)
InString = Right$(InString, StringLength - i)
If (Asc(TempString) >= 65 And Asc(TempString) <= 90) Or _
(Asc(TempString) >= 97 And Asc(TempString) <= 122) Or _
(Asc(TempString) >= 48 And Asc(TempString) <= 57) Then
OutString = OutString & TempString
End If
Next i
Cleanse = OutString
End Function