Solved

selecting text

Posted on 2000-04-03
10
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 1 hour left to enroll

626 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