Solved

selecting text

Posted on 2000-04-03
10
151 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 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

20 Experts available now in Live!

Get 1:1 Help Now