M
Maury Markowitz
I've read in a few places that the Replace function is slow, and is a
potential performance problem. I have a function that is called
thousands of times during one lengthy operation...
Public Function CleanString(aString)
temp = aString
temp = Replace(temp, " ", "")
temp = Replace(temp, vbTab, "")
temp = Replace(temp, vbCrLf, "")
temp = Replace(temp, vbCr, "")
temp = Replace(temp, vbLf, "")
temp = Replace(temp, ";", "")
temp = Replace(temp, ",", "")
temp = Trim(temp)
CleanString = temp
End Function
Is there a better way to do this? Should I use instr to test before
replacing? Is there some sort of "replace anything in this list
with...". Anything else I should consider?
Maury
potential performance problem. I have a function that is called
thousands of times during one lengthy operation...
Public Function CleanString(aString)
temp = aString
temp = Replace(temp, " ", "")
temp = Replace(temp, vbTab, "")
temp = Replace(temp, vbCrLf, "")
temp = Replace(temp, vbCr, "")
temp = Replace(temp, vbLf, "")
temp = Replace(temp, ";", "")
temp = Replace(temp, ",", "")
temp = Trim(temp)
CleanString = temp
End Function
Is there a better way to do this? Should I use instr to test before
replacing? Is there some sort of "replace anything in this list
with...". Anything else I should consider?
Maury