While I was waiting I came up with this procedure, that for the most part,
solves my problem, but I'm a novice and would like to know if it is good or
bad programimg. I like that I don't have to guess what is coming up in the
text to deal with, except for a few, and that could be a plus.
'with var106 as text variable, following loop strips all punctuation, except
for ^_[ ]\ at least as far as I could find
var111 = Len(var106)
var114 = ""
Do Until var111 = 0
If Left(var106, 1) Like "[aA-zZ]" Then
var111 = Len(var106)
var113 = Left(var106, 1)
var114 = var114 & var113
var106 = Mid(var106, 2, var111)
Else:
var111 = Len(var106)
var106 = Mid(var106, 2, var111)
End If
Loop
var106 = var114 ' ends punctuation removal
John Spencer (MVP) said:
This would require a custom function
UNTESTED AIR CODE - Not as efficient as it could be, but it should work
Public Function fStripPunctuation(strIN)
Dim lngChar as Long
Dim lngCount as Long
Dim strReturn as String
Dim strSkipChar as string
If IsNull(StrIN) then
fStripPunctuation = Null
exit function
Else
strSkipChar = ".,!?:;" 'All punctuation characters
'Add any others that you want to include such as (,{,[
lngChar = Len(strIn & vbNullString)
For lngCount = 1 to lngChar
If Instr(1,strSkipChar, Mid(strIn,lngcount,1) ) = 0 then
strReturn = strReturn & Mid(strIn,lngCount,1)
End If
Next lngCount
End if
fStripPunctuation = strReturn
End Function
John said:
Is there a way to Remove all punctuation from a text string, without
identifying each type, if not what is the best way to do it with the text as
variable.
Thanks John