[AccessD] Replace Special Characters

Stuart McLachlan stuart at lexacorp.com.pg
Thu Apr 10 18:42:05 CDT 2003


On 10 Apr 2003 at 15:07, Drew Wutka wrote:

>  if IsNumeric(mid(strOriginal,i,1)) Or _
>  (Asc(mid(UCase(strOriginal),i,1))>=65 And _
>  Asc(mid(UCase(strOriginal),i,1))<=90) Then

If you are using it on a lot of records, it would probably be worth optimizing it with:

Dim strChar As String
Dim lngAsc As Long
......
strChar = Mid$(strOriginal, i, 1)
lngAsc = Asc(UCASE$(strChar))
If IsNumeric(strChar) Or (lngAsc >= 65 And lngAsc <= 90) Then
    strTemp=strTemp & strChar
....

The Mid() and Ucase() functions return a variant, the Mid$() and Ucase$() functions 
return a string  which is quicker to manipuate subsequentlty.

Evaluating Mid$() once and then using a defined string for subsequent operations will 
also shave time.

Actually, I  suspect this would be even quicker:


Dim strUnwanted as String
......
strwanted = 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
.......
strChar = Mid$(strOriginal, i, 1)
If Instr(strWanted,StrChar) Then  strTemp=strTemp & strChar



-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.





More information about the AccessD mailing list