BUG: SelText in Edit Box Limited to 255 Characters

Last reviewed: July 30, 1997
Article ID: Q172088
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a
  • Microsoft Visual FoxPro for Macintosh, version 3.0b

SYMPTOMS

In Visual FoxPro 3.x and 5.x for Windows and Visual FoxPro 3.0b for the Macintosh, the SelText property for an Editbox selects only up to 255 characters.

RESOLUTION

The workaround is to use the SUBSTR function as illustrate below:

   SelectedText = SUBSTR(ThisForm.edit1.Value, ;
                         ThisForm.edit1.SelStart + 1, ;
                         ThisForm.edit1.SelLength)

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a program with the following code:

          PUBLIC x
          x=CREATEOBJECT('form1')
          x.Show
    

          DEFINE CLASS form1 AS form
    

             Top = 0
             Left = 0
             Height = 250
             Width = 425
             DoCreate = .T.
             Caption = "Form1"
             Name = "Form1"
    
             ADD OBJECT edit1 AS editbox WITH ;
               Height = 229, ;
               Left = 11, ;
               Top = 10, ;
               Width = 276, ;
               Name = "Edit1"
    
             ADD OBJECT command1 AS commandbutton WITH ;
               Top = 25, ;
               Left = 300, ;
               Height = 27, ;
               Width = 84, ;
               Caption = "Click Me", ;
               Name = "Command1"
    
             PROCEDURE edit1.Init
               This.HideSelection = .F.
               This.Value = REPLICATE( "abcedfghijklmnopqrstuvwxyz", 15 )
               This.SelStart = 0
               This.SelLength = LEN( This.Value )
             ENDPROC
    
             PROCEDURE command1.Click
               =MESSAGEBOX("SelLegth "+STR(Thisform.edit1.SelLength))
               =MESSAGEBOX("SelText "+STR(LEN(Thisform.edit1.SelText)))
               =MESSAGEBOX(Thisform.edit1.SelText)
             ENDPROC
    
          ENDDEFINE
    
    

  2. Run the .prg file and click the CLICK ME button.

The second message box shows only 255 characters for the SelText property instead of 390.

Keywords          : FxprgClassoop kbcode
Version           : MACINTOSH:3.0b; WINDOWS:3.0,3.0b,5.0,5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbbug


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.