From: prel@post.tele.dk   
      
   "Stephen Saunders" skrev i en meddelelse   
   news:6pCYd.1661$qW.357@newsread3.news.atl.earthlink.net...   
   > Hey Folks,   
   >   
   > This one currently has me stumped. I have to check for the   
   > existence of a carriage return (Enter key, hex 0D) in text data.   
   > First I tried:   
   >   
   > 'Check comment to not contain the CR (13) character   
   > For i = 1 To Len(txtComment.Text)   
   > On Error GoTo BogusComment2   
   > If Mid(txtComment.Text, i, 1) = CStr(13) Then   
   > MsgBox "Comment cannot contain the enter character"   
   > 'Strip the CR from the comment   
   > txtComment.Text = Left(txtComment.Text, (i - 1)) + _   
   > Right(txtComment.Text, (Len(txtComment.Text) - i))   
   > Exit Sub   
   > End If   
   > On Error GoTo 0   
   > Next i   
   >   
   > This doesn't find the CR because CStr(13) equals a two character   
   > string   
      
   CStr(13) is NOT a CR, CStr(13) is "13" ! CHR(13) is a CR ! ;-)   
      
   And what's wrong with   
      
   IF instr(1, txtComment.Text, vbCR) > 0 the   
    MsgBox "Comment cannot contain the enter character"   
      
    txtComment.Text = Replace(txtComment.Text, vbCR, "")   
   End IF   
      
      
   --   
   /\ preben nielsen   
   \/\ prel@post.tele.dk   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|