FIX: SelText Does Not Return Last Character in Text Box

ID: Q183257


The information in this article applies to:


SYMPTOMS

If the selected text within a textbox includes the last character of the controls Text property, the SelText property will not include the last character.


RESOLUTION

To work around this problem, you can use the SelStart and SelLength properties to capture the selected string:


   Dim strSelected

   If Text1.SelLength > 0 then
      strSelected = Mid(Text1.Text, Text1.SelStart + 1, Text1.SelLength)

   End If 


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.


MORE INFORMATION

When the selected text includes the last character of the control's Text property, the SelText property will not include the last character.

For example, assume a textbox control contains the characters "this is a test" (without the quotation marks):


+----------------------------------------------------------------+
|    If the selected text is:     |         SelText Property     |
+----------------------------------------------------------------+
|      "is a test"                |            "is a tes"        |
+----------------------------------------------------------------+
|      "This is a"                |            "This is a"       |
+----------------------------------------------------------------+ 


REFERENCES

Books Online for Microsoft Windows CE Toolkit for Visual Basic 5.0

Additional query words: VBCE wce selection vbce5 vbce6


Keywords          : kbToolkit kbVBp kbVBp500bug kbVBp600fix kbWinCE kbWinCE100 kbGrpVB 
Version           : WINDOWS:1.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: March 3, 1999