Solved

selecting text

Posted on 2000-04-03
10
150 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now