Results 1 to 9 of 9

Thread: how to auto tab or move to nxt txt box automatically wn took data frm Bar code reader

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    11

    Question how to auto tab or move to nxt txt box automatically wn took data frm Bar code reader

    Hi
    i am old programmer and start programming after 14 year.
    i am facing problem in auto tab or move to next text box automatically when took data from bar code reader.

    please expaln. i took codes from in form posted in 2010 or 12 but these are not working. showing red error when pasted.


    both these are not working or please guide am i missing some thing to declare or so?


    -------------------------------------------------------------------------------------------------------
    Private Sub CheckEntry(ByVal sender As Object, ByVal e As System.EventArgs) Handles Text1.TextChanged, Text2.TextChanged, _
    Text3.TextChanged, Text4.TextChanged, _
    Text5.TextChanged, Text6.TextChanged, _
    Text7.TextChanged, Text8.TextChanged

    Dim TB As TextBox = CType(sender, TextBox)
    If TB.Text.Length = TB.MaxLength Then
    'IF YOU WANT IT TO ONLY GO TO THE NEXT TEXTBOX AUTOMATICALLY IF THEY ARE AT
    'THE LAST CHARACTER OF THE TEXTBOX, THEN WE NEED TO CHECK THE SELECTIONSTART
    'PROPERTY, OTHERWISE YOU CAN REMOVE THAT CHECK, THIS IS USEFUL IF SOMEONE MAKES
    'A MISTAKE AND HAS TO GO CHANGE THE VALUE IN THE TEXTBOX
    If TB.SelectionStart = 4 Then
    Me.SelectNextControl(TB, True, True, False, False)
    End If
    End If

    End Sub
    ---------------------------------------------------------
    Private Sub Text1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Text1.KeyPress
    'Suppress all key presses that are not "0", "1" or a control character.
    e.Handled = (e.KeyChar <> "0"c AndAlso e.KeyChar <> "1"c AndAlso Not Char.IsControl(e.KeyChar))
    End Sub

  2. #2

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    11

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    I am Using vb6

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    Most of the time I add a CR to the end of the barcode in the reader properties. I then trap the CR in the keypress event and when it gets the CR then it validates the entry if the entry is ok then the code will set focus to the next text box if there is one or it may be that it needs to save the data and clear the screen and move back to the first text box and of course if there is something wrong with the entry a message and/or sound is used to let the user know the entry was not accepted and focus remains on the current field.

    In windows programs the TAB key may be more desirable here. I do a lot of coding for mobile devices and the enter key just works better there and of course works just fine on the PC as well.

    btw the code you posted is VB.Net so it will not work in VB6

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    11

    Question Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    can you help me for VB6

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    Did you understand DataMiser first paragraph? If so, you should be able to figure it out (old programmer or new).
    Sam I am (as well as Confused at times).

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2021
    Posts
    11

    Question Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    I am very old programmer. Start programming after 2007 again.
    I under stand 1st paragraph half.
    Where you discussed (CR …..) that part doesn’t understand

    Right now i am using length method

    If len(text1.text)=>13 then text2.setfocus

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,415

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    Quote Originally Posted by shankh View Post
    I am very old programmer. Start programming after 2007 again.
    I under stand 1st paragraph half.
    Where you discussed (CR …..) that part doesn’t understand

    Right now i am using length method

    If len(text1.text)=>13 then text2.setfocus
    The code you found (and copy/pasted) is VB.NET
    It's not going to work in VB6 regardless what you do
    You have to rewrite it to VB6
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    CR=Carriage Return....an old expression brought forward from the days of the TYPEWRITER. On most English Keyboards for computers, it is represented by the "Enter" Key. In ASCII it is represented by Decimal 13.
    Sam I am (as well as Confused at times).

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: how to auto tab or move to nxt txt box automatically wn took data frm Bar code re

    Small sample
    Code:
    Option Explicit
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        'check to see if entry is valid
        If IsNumeric(Text1.Text) Then
            Text2.SetFocus
        Else
            MsgBox "Invalid Entry"
            Text1.Text = ""
        End If
        KeyAscii = 0
    End If
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width