Hi Philip,

The first character in a string is numbered 1.
I don't know what mid() returns for character 0 but my guess is that's 
what causes your problem. It's not in the illegal characters, so your 
second loop works fine, but it's not in the legal characters either.
Try changing your code to :

  for c = 1 to len(self.BookcodeField.text)

Hope that helps.

Octave

Le 3 mai 07, à 22:43, [EMAIL PROTECTED] a écrit :

> 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
>
>      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]
>
> When I enter a legal character InStr returns 0 regardless of how much 
> text I have in the editField. However, the following code works fine 
> (I used this in the previous version):
>
>  [code]
>  dim c as integer
>  dim IllegalCharacters as string
>
>  IllegalCharacters = "[EMAIL PROTECTED]&*()+={[}]|\:;<,>.?/~`'-"""
>
>  if self.BookcodeField.text <> "" then
>    for c = 0 to len(self.BookcodeField.text)
>      if InStr(IllegalCharacters, 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]
>
>  Is there some other invisible character I should be looking for? Or 
> is there some subtle bug in my code that I'm missing?
>
>  Thanks
>  --
>  Philip Regan
>  [EMAIL PROTECTED]
>  RB2K7r2, Mac OS 10.4.9, PowerPC G5


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to