Dachande11
Registered User.
- Local time
- Today, 10:05
- Joined
- May 1, 2001
- Messages
- 41
Here is my problem:-
I need a function to check for unwanted characters in a field (for example ("," " ",""") and then replace them with a single space.
I think I have found a piece of code from an old employee which was designed for this purpose, but being a total beginner I do not understand why it is not working and what I need to do to fix it. Here is the code:
Option Compare Database
Option Base 1
Public Function AddrCheck(sString As String)
Dim ChkCharArray() As Variant
ChkCharArray(1) = " "
ChkCharArray(2) = Chr(39) ' '
ChkCharArray(3) = Chr(44) ' ,
ChkCharArray(4) = Chr(34) ' "
X = 1
For c = 1 To Len(sString)
Y = 1 'Sets starting position of array
For z = 1 To UBound(ChkCharArray)
sString = Replace(sString, ChkCharArray(Y), " ")
Y = Y + 1
Next z
X = X + 1
Next c
End Function
I thank in advance for anyone who can help me.
Mark
I need a function to check for unwanted characters in a field (for example ("," " ",""") and then replace them with a single space.
I think I have found a piece of code from an old employee which was designed for this purpose, but being a total beginner I do not understand why it is not working and what I need to do to fix it. Here is the code:
Option Compare Database
Option Base 1
Public Function AddrCheck(sString As String)
Dim ChkCharArray() As Variant
ChkCharArray(1) = " "
ChkCharArray(2) = Chr(39) ' '
ChkCharArray(3) = Chr(44) ' ,
ChkCharArray(4) = Chr(34) ' "
X = 1
For c = 1 To Len(sString)
Y = 1 'Sets starting position of array
For z = 1 To UBound(ChkCharArray)
sString = Replace(sString, ChkCharArray(Y), " ")
Y = Y + 1
Next z
X = X + 1
Next c
End Function
I thank in advance for anyone who can help me.
Mark