Highlighting a text box for data entry..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CRSI
    New Member
    • Sep 2006
    • 6

    Highlighting a text box for data entry..

    Hi folks,

    In learning VB I've designed a little program which requires user input of time hh:mm. The field is selected when the form opens (due to tab order) but the cursor bar is to the left of the default entry (00:00). How can I present the text box in such a way as to allow immediate input by the user? Currently they must grab their mouse and double click inside the (already active) box in order to fully select the contents for replacement.

    Secondly, how can I force the execution of a command button upon the user pressing enter after the original data entry?

    I realize these may be basic questions (I'm basically a beginner). Sadly, I've yet to learn enough of the "lexicon" of VB to ask intelligent questions or find references in the documentation.

    Any light you can shine on this would be appreciated,

    Thanks!
  • Rahna
    New Member
    • Aug 2006
    • 12

    #2
    I'm not sure whether this is the right way to do this, but the code given below will help you to select the text.

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

    And to click a command button by pressing the 'Enter' key, set the 'Default' property of the button to 'True'.

    Comment

    • CRSI
      New Member
      • Sep 2006
      • 6

      #3
      Originally posted by Rahna
      I'm not sure whether this is the right way to do this, but the code given below will help you to select the text.

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

      And to click a command button by pressing the 'Enter' key, set the 'Default' property of the button to 'True'.
      The tip on setting the default propoerty of the command button worked great.
      However, I still can't seem to get the Text box in which I'm asking for user input to present a select all condition.

      I'm asking the user to enter the time stamped on a ticket. Currently in the "text" property of the text box I've provided 00:00 and thinking it would help I selected "data format" Time (17:55 for example).

      Now I'm thinking that I'll have to approach it another way, perhaps setting the SelStart and SelLength when the focus is on that field.

      Then there is the whole issue of error checking to prevent the user from putting in an "illegal" time like 99:67. When that happens now get a "type mismatch" error message that pops up. I'll get there eventually.

      Thanks for your willingness to chime in and give me a boost!

      Regards

      Comment

      Working...