Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

text box selection when execute form

Posted on 2002-03-06
5
Medium Priority
?
175 Views
Last Modified: 2010-05-02
1. i design a form so i want that when text box got focus previously displayed values should be selected.

if i want to change the value simply i press delete key from the keyboard and enter new value.
2.
what is the way when i input value in text box it convert in caps whenever caps lock key is off.


0
Comment
Question by:pak_slm
  • 3
5 Comments
 
LVL 1

Expert Comment

by:surajdeo
ID: 6846639
Hi,

 1. On gotfocus for selecting text write following code.


 Private Sub Text1_GotFocus()

    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
   
 End Sub


2. For caps

Private Sub Text1_KeyPress(KeyAscii As Integer)

    If KeyAscii >= 97 And KeyAscii <= 122 Then KeyAscii = KeyAscii - 32
   
End Sub
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 6846669
Private Sub Text1_Change()
    Text1.Text = UCase$(Text1.Text)
End Sub

Private Sub Text1_Click()
    SendKeys "{Home}+{End}"
End Sub
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 6846672
Oops, Private Sub Text1_Click() should be: Private Sub Text1_GotFocus()
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 6846872
Hi, Why "C" is graded?!
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6859522
Grade changed; comment (as corrected) is accurate, simple and works.

pak_slm,

A simple answer is usually the best answer. Please do not grade based on the number of characters typed into a response, but rather on whether or not you understand it and use it.

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

824 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