Solved

selecting text

Posted on 2000-04-03
10
153 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 54
VBA color chart bars 12 85
Change the path of the data source in my Excel pivot table with macro 4 43
Adding to a VBA? 6 70
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

770 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