Link to home
Start Free TrialLog in
Avatar of csindorf
csindorf

asked on

selecting text

another one that has slipped by me please.

after an error is determined and I have setfocus back into the box I want to select all the text in that box so the user can renter it.

TIA

Craig
Avatar of AzraSound
AzraSound
Flag of United States of America image

text.sellength = len(text)
Try this:

Private Sub Text1_GotFocus()
  ' Select all text
  Text1.SelStart = 0
  Text1.SelLength = Len(Text1.Text)
End Sub


Regards,
Grant.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of skip99
skip99

'textbox.SetFocus
textbox.selstart = 0
textbox.sellength = Len(textbox.text)
Skip99
I do not see how your code is any different than the other comments.  If the question has already been answered as a comment, the questioner can accept a comment as answer.  Since your "answer" is not unique, you have the option to "withdraw" your proposed answer.
skip99 changed the proposed answer to a comment
Friends. Skip99 and Erick37. Both of u gave correct answers but correct me if i am wrong. The set focus should come last in the line of coding.Right?

Like This:

Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.Setfocus

<Smiling> csindorf. To whom u r gonna award points. <Smile>

csindorf stated that he already set focus back to the box, so all that was left was to select the string


text.sellength = len(text.text)
And also the Start position,
i.e. Text1.SelStart = 0
Avatar of csindorf

ASKER

First one in won the candy bar.  :-)