Can I, and then how do I program in such a manner as to prevent the
introduction of any garbage (ESC, etc.) characters from the user interface to
be accepted by the db? I have seen ASCII? characters ... squares, fields that
look blank but are not, etc. Please help.
Hi Andy,
I don't know exactly how you intend to implement your idea but, I have an
application that pulls data from Word forms and the yo-yos that fill in these
forms do things that really leave me scratching my head and pondering the future
of our species. Anyway, below are a couple of functions I use to scrub input
strings. If you understand what they do you should be able to alter/adapt them
to work for you. They work fine in my application but I make no guarantees.
Watch out for word wrap.
Have fun,
RD
<code>
Function fExtractStr(ByVal sStringIn As String) As String
Dim lLen As Long, sStringOut As String
Dim i As Long, sTemp As String
lLen = Len(sStringIn)
sStringOut = ""
For i = 1 To lLen
sTemp = Left$(sStringIn, 1)
sStringIn = Right$(sStringIn, lLen - i)
' ASCII characters 65-90 are upper case, 97-122 are lower case and 32 =
Space
If (Asc(sTemp) >= 65 And Asc(sTemp) <= 90) Or _
(Asc(sTemp) >= 97 And Asc(sTemp) <= 122) Or _
(Asc(sTemp)) = 32 Then
sStringOut = sStringOut & sTemp
End If
Next i
fExtractStr = Trim(sStringOut)
fExtractStr = Left(fExtractStr, 50)
End Function
Function fExtractNum(ByVal sStringIn As String) As Currency
Dim lLen As Long, sStringOut As String
Dim i As Long, sTemp As String
lLen = Len(sStringIn)
sStringOut = ""
For i = 1 To lLen
sTemp = Left$(sStringIn, 1)
sStringIn = Right$(sStringIn, lLen - i)
' ASCII characters 48-57 = numbers 0-9
If Asc(sTemp) >= 48 And Asc(sTemp) <= 57 Then
sStringOut = sStringOut & sTemp
End If
Next i
If IsNumeric(sStringOut) Then
sStringOut = Trim(sStringOut)
sStringOut = Left(sStringOut, 10)
fExtractNum = CCur(Trim(sStringOut))
Else
fExtractNum = 0
End If
End Function
</code>