On 5/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Howdy--
>
> This could be just me, but I'm finding something odd working with an
> EditField... I have an EditField ("BookcodeField", single line, no encoding
> specified) where a user enters text and then in a PushButton, the text gets
> checked for any weird characters that isn't allowed by a system I'm working
> with. Here's the code:
>
> [code]
> dim c as integer
> dim LegalCharacters as string
>
> LegalCharacters =
> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"
>
> if self.BookcodeField.text <> "" then
> for c = 0 to len(self.BookcodeField.text)
> if InStr(LegalCharacters, mid(self.BookcodeField.text, c, 1)) = 0 then
> return ErrorMsgBox("The Bookcode field contains an illegal character.")
> end if
> next
> else
> return ErrorMsgBox("The Bookcode field needs an entry.")
> end if
> [/code]
I assume you've got this in a LostFocus handler or somewhere else that
post-processes the text in the EditField. I'd suggest instead putting
an InStr check against LegalCharacters in your EditField's KeyDown
event handler. For example,
if Instr(LegalCharacters, key) = 0 Then
beep
return True
end if
That way users will now right away that they can't enter a particular
character. You may want to post-process code that has been dropped or
pasted in the TextChange handler with a loop such as you're using.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>