Return Key

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    #1

    Return Key

    I am new to VB.Net and I am developing a stand-alone app
    that will only be using a RF scanner to enter
    information. I was curious if anyone knew of any articles
    or source code on how I could get the text box to execute
    to TAB/ENTER when a certain number of characters have been
    reached within a text box.
  • Vlad

    #2
    Re: Return Key

    Chris,
    maybe this code will help you. Place 2 textboxes on the form and write this
    code

    Private Sub TextBox1_KeyPre ss(ByVal sender As Object, ByVal e As
    System.Windows. Forms.KeyPressE ventArgs) Handles TextBox1.KeyPre ss
    If Len(TextBox1.Te xt) >= 5 Then
    e.Handled = True
    Call Done()
    End If
    End Sub

    Private Sub Done()
    TextBox2.Select ()
    TextBox2.Text = "No more characters. Do something else"
    End Sub

    You can call any sub or function instead of my DONE sub
    Vlad

    "Chris" <chris.boone@tb gamericas.com> wrote in message
    news:008a01c36d 83$84b2a770$a40 1280a@phx.gbl.. .[color=blue]
    > I am new to VB.Net and I am developing a stand-alone app
    > that will only be using a RF scanner to enter
    > information. I was curious if anyone knew of any articles
    > or source code on how I could get the text box to execute
    > to TAB/ENTER when a certain number of characters have been
    > reached within a text box.[/color]


    Comment

    • Chris

      #3
      Re: Return Key

      Will this code recognize when the user presses the ENTER
      key?
      [color=blue]
      >-----Original Message-----
      >Chris,
      >maybe this code will help you. Place 2 textboxes on the[/color]
      form and write this[color=blue]
      >code
      >
      >Private Sub TextBox1_KeyPre ss(ByVal sender As Object,[/color]
      ByVal e As[color=blue]
      >System.Windows .Forms.KeyPress EventArgs) Handles[/color]
      TextBox1.KeyPre ss[color=blue]
      > If Len(TextBox1.Te xt) >= 5 Then
      > e.Handled = True
      > Call Done()
      > End If
      >End Sub
      >
      >Private Sub Done()
      > TextBox2.Select ()
      > TextBox2.Text = "No more characters. Do something[/color]
      else"[color=blue]
      >End Sub
      >
      >You can call any sub or function instead of my DONE sub
      >Vlad
      >
      >"Chris" <chris.boone@tb gamericas.com> wrote in message
      >news:008a01c36 d83$84b2a770$a4 01280a@phx.gbl. ..[color=green]
      >> I am new to VB.Net and I am developing a stand-alone app
      >> that will only be using a RF scanner to enter
      >> information. I was curious if anyone knew of any[/color][/color]
      articles[color=blue][color=green]
      >> or source code on how I could get the text box to[/color][/color]
      execute[color=blue][color=green]
      >> to TAB/ENTER when a certain number of characters have[/color][/color]
      been[color=blue][color=green]
      >> reached within a text box.[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Schfooge

        #4
        Re: Return Key

        "Chris" <chris.boone@tb gamericas.com> wrote in message
        news:008a01c36d 83$84b2a770$a40 1280a@phx.gbl.. .[color=blue]
        > I am new to VB.Net and I am developing a stand-alone app
        > that will only be using a RF scanner to enter
        > information. I was curious if anyone knew of any articles
        > or source code on how I could get the text box to execute
        > to TAB/ENTER when a certain number of characters have been
        > reached within a text box.[/color]

        By doing a "Tab", i'm guessing you mean shifting the focus
        to the next textbox. That would be done like this:

        Private Sub txtOne_TextChan ged(ByVal sender As System.Object, _
        ByVal e As System.EventArg s) Handles txtOne.TextChan ged

        'where txtOne and txtTwo are two textboxes on the form
        If txtOne.Text.Len gth = 5 Then
        txtTwo.Focus()
        End If
        End Sub

        By doing and enter, I presume you want some action(s) to occur
        when the box is full. For this, put the action into a sub(eg. MySub)
        and call the sub like this:

        Private Sub txtTwo_TextChan ged(ByVal sender As System.Object, _
        ByVal e As System.EventArg s) Handles txtTwo.TextChan ged

        If txtOne.Text.Len gth = 5 Then
        Call MySub()
        End If
        End Sub

        Hope this helps,


        Comment

        Working...