Microsoft KB Archive/313196

= PRB: SET DATE Resets SelStart Property in Text Boxes =

Article ID: 313196

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q313196



SYMPTOMS
If you change the value of SET(&quot;DATE&quot;) while the focus is in a text box, the SelStart property is reset to 0, placing the insertion point before the first character. This occurs even if the form is in a different data session than the one in which you perform the SET DATE.



RESOLUTION
You can partially work around this behavior by saving and restoring the SelStart property in the routine that performs the SET DATE. FOR i = 1 TO _SCREEN.FormCount loScreenForm = _SCREEN.Forms(i) IF TYPE(&quot;loScreenForm.ActiveControl.SelStart&quot;) = &quot;N&quot; loScreenForm.Tag = STR(loScreenForm.ActiveControl.SelStart) ENDIF ENDfor

SET DATE TO (SET(&quot;DATE&quot;)) && This line will reset the SelStart property.

FOR i = 1 TO _SCREEN.FormCount loScreenForm = _SCREEN.Forms(i) IF TYPE(&quot;loScreenForm.ActiveControl.SelStart&quot;) = &quot;N&quot; loScreenForm.ActiveControl.SelStart = VAL(loScreenForm.Tag) ENDIF ENDFOR



Steps to Reproduce Behavior
Run the following code to see the behavior in any version of Visual FoxPro: PUBLIC oForm oForm = CREATEOBJECT(&quot;Form&quot;) oForm.Show oForm.AddObject(&quot;txtBox&quot;, &quot;textbox&quot;) oForm.txtBox.Visible = .T.

oForm.txtBox.SetFocus oForm.txtBox.Value = &quot;12345&quot; oForm.txtBox.SelStart = LEN(oForm.txtBox.Value) ? oForm.txtBox.SelStart && will be 5

SET DATE TO (SET(&quot;DATE&quot;)) ? oForm.txtBox.SelStart && will be 0 NOTE: Although these examples all show the behavior within a form, you may also see this behavior when running a process from a timer that parses external data.

Keywords: kbbug kbnofix kbcodesnippet kbprb KB313196

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.