Selecting text in a text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Franklin Park
    New Member
    • Dec 2006
    • 2

    #1

    Selecting text in a text box

    Hi,
    First off, I will apologize in advance for any breaches in etiqutte I make. I am barely a programmer who is learning what I can on my own. With that being said, I am working a very simple program to calculate profits. The user enters costs and sell prices and the app calculates the profit.I am using text boxes for the data entry. I would like a certain text box to be selected on running the program and then the boxes to select as the user tabs thru the boxes. I have looked through the info here and tried a couple of things but none have worked. Probably my fault. Any thoughts? Please don't be afraid to insult me by dumbing it down!
    Thanks,
    Gary
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by Franklin Park
    Hi,
    First off, I will apologize in advance for any breaches in etiqutte I make. I am barely a programmer who is learning what I can on my own. With that being said, I am working a very simple program to calculate profits. The user enters costs and sell prices and the app calculates the profit.I am using text boxes for the data entry. I would like a certain text box to be selected on running the program and then the boxes to select as the user tabs thru the boxes. I have looked through the info here and tried a couple of things but none have worked. Probably my fault. Any thoughts? Please don't be afraid to insult me by dumbing it down!
    Thanks,
    Gary
    Hi Gary. If you adjust the tab order on your form you can control the order of the textboxes as the user presses tab. You can set the first text box to be first in the tab order of your controls so that it will have the focus when the form opens.
    good luck

    Comment

    • rockford333
      New Member
      • Sep 2006
      • 15

      #3
      Originally posted by Franklin Park
      Hi,
      First off, I will apologize in advance for any breaches in etiqutte I make. I am barely a programmer who is learning what I can on my own. With that being said, I am working a very simple program to calculate profits. The user enters costs and sell prices and the app calculates the profit.I am using text boxes for the data entry. I would like a certain text box to be selected on running the program and then the boxes to select as the user tabs thru the boxes. I have looked through the info here and tried a couple of things but none have worked. Probably my fault. Any thoughts? Please don't be afraid to insult me by dumbing it down!
      Thanks,
      Gary

      Hi,
      Just use the tab order it will select the text automaticaaly. If u face problem in that u can use this type also u can use in the textbox which u want to select u can write in the gotfocus event if u r using text1 then text1.setfocus. Tell me if u have any problem are if u succed also.

      Comment

      • Franklin Park
        New Member
        • Dec 2006
        • 2

        #4
        Hi Willa & Rockford
        Originally posted by rockford333
        Hi,
        Just use the tab order it will select the text automaticaaly. If u face problem in that u can use this type also u can use in the textbox which u want to select u can write in the gotfocus event if u r using text1 then text1.setfocus. Tell me if u have any problem are if u succed also.
        Thanks. I had already set the tab order. When I tab through the text boxes tho the cursor is at the beginning of the default which is typically 0.00. If I use the setfocus where do I put it in the code?
        Thanks again for your assistance.
        Gary

        Comment

        • willakawill
          Top Contributor
          • Oct 2006
          • 1646

          #5
          Originally posted by Franklin Park
          Hi Willa & Rockford


          Thanks. I had already set the tab order. When I tab through the text boxes tho the cursor is at the beginning of the default which is typically 0.00. If I use the setfocus where do I put it in the code?
          Thanks again for your assistance.
          Gary
          You can control the selection in your text box using the gotfocus event:

          Code:
          Private Sub txtRight_GotFocus()
              If Len(txtRight.Text) > 0 Then
                  txtRight.SelStart = 0
                  txtRight.SelLength = Len(txtRight.Text)
              End If
          End Sub

          Comment

          Working...