Solved

selecting text

Posted on 2000-04-03
10
154 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:csindorf
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2681617
text.sellength = len(text)
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2681631
Try this:

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


Regards,
Grant.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 20 total points
ID: 2681637
Private Sub Text1_LostFocus()
    If Not (IsNumeric(Text1.Text)) Then
        MsgBox "Please enter only a number"
        Text1.SetFocus
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
    End If
End Sub
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:skip99
ID: 2681932
'textbox.SetFocus
textbox.selstart = 0
textbox.sellength = Len(textbox.text)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2681959
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.
0
 
LVL 1

Expert Comment

by:skip99
ID: 2682019
skip99 changed the proposed answer to a comment
0
 

Expert Comment

by:AshokKumar
ID: 2682805
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>

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2682820
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)
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2683239
And also the Start position,
i.e. Text1.SelStart = 0
0
 

Author Comment

by:csindorf
ID: 2683662
First one in won the candy bar.  :-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question