none
Invoice recall data from access RRS feed

  • Question

  • Hello there 

    I need some help

    I have design simple vb form

    And make connect with access file *oledb*

    I have to scan barcode at tect box and the form identify items

    Result .

    Item 1 ... desc ... price ... 

    Item 2.... desc .. price

    Etc...

    Then save it as text

    The problem i dont know how to make the form decode barcode and give me the product 

    Sorry for amateur question.

    Tuesday, June 19, 2018 1:51 PM

All replies

  • I use a barcode font called 3of9 and is widely available online.

    Dont use a textbox, use a label to hold the barcode.

    You will need to add a "*" at the begining and end of the code

    IE:

    label1.text = "*" & YourCode & "*"
    
    At hich point your barcode reader can read


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Tuesday, June 19, 2018 1:57 PM
  • I have to scan barcode at tect box and the form identify items

    ...

    The problem i dont know how to make the form decode barcode and give me the product 

    The scanning and decoding of a barcode is a function of the software associated with your barcode scanner.  Most scanners come with software that supports "keyboard wedge" functionality, meaning, the scanned barcode is decoded and the text is sent to the active text control of whatever program has focus.  Essentially, the barcode scanner "types" the decoded data into your program.  While this is typically a very easy solution to setup, it does require that the user have focus on the correct textbox before scanning. 

    Other hardware solutions include their own API which allows you to more directly integrate the scanner with your software.  With an API, your code can react to a scan and do whatever it wants with the decoded data.

    Either way, this is a function of the hardware you use to scan barcodes, not something your Form would handle.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, June 19, 2018 3:16 PM
    Moderator
  • Hi Letemoin,

    According to your description, I guess that you want to get product's info when you scan code, am I right? If yes, you can add the following code in textbox_textchanged event, to get some info into listbox.

    Imports System.Data.SqlClient
    Public Class Form1
        Dim conn As SqlConnection = New SqlConnection("Data Source = (localdb)\MSSQLLocalDB; Integrated Security = True ;AttachDbFileName= C:\Users\alexl2\Desktop\DataBase\Alex\alex.mdf")
        Dim cmd As SqlCommand
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            conn.Open()
        End Sub
        Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
            Dim id As Integer = TextBox1.Text
            cmd = New SqlCommand("select * from Barcode where BarcodeId=@id", conn)
            cmd.Parameters.AddWithValue("@id", id)
            Dim sdr As SqlDataReader = cmd.ExecuteReader()
            While sdr.Read = True
                ListBox1.Items.Add("Price:" & sdr(1) & "  " & "Desc:" & sdr(2))
            End While
            conn.Close()
        End Sub
    End Class
    
    

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 20, 2018 2:36 AM
    Moderator
  • Hi Letemoin,

    According to your description, I guess that you want to get product's info when you scan code, am I right? If yes, you can add the following code in textbox_textchanged event, to get some info into listbox.

    Imports System.Data.SqlClient
    Public Class Form1
        Dim conn As SqlConnection = New SqlConnection("Data Source = (localdb)\MSSQLLocalDB; Integrated Security = True ;AttachDbFileName= C:\Users\alexl2\Desktop\DataBase\Alex\alex.mdf")
        Dim cmd As SqlCommand
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            conn.Open()
        End Sub
        Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
            Dim id As Integer = TextBox1.Text
            cmd = New SqlCommand("select * from Barcode where BarcodeId=@id", conn)
            cmd.Parameters.AddWithValue("@id", id)
            Dim sdr As SqlDataReader = cmd.ExecuteReader()
            While sdr.Read = True
                ListBox1.Items.Add("Price:" & sdr(1) & "  " & "Desc:" & sdr(2))
            End While
            conn.Close()
        End Sub
    End Class
    

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Not sure I would go about it this way. It looks like your connection will stay open until you scan something then close the connection. Then the connection would be close for next scan. Also I would use KeyUp and not Text Changed so you can check for Keys.Enter. A barcode scanner will trigger this event as well as the enter key assuming its programmed as such (all the scanners ive bought come like this by default) My code would look something more like this

    Imports System.Data.OleDb
    
    Public Class ScanExample
        Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
            If e.KeyCode = Keys.Enter Then
                Using AccessConn As New OleDbConnection("Your Connection String")
                    AccessConn.Open()
                    Using DR As OleDbDataReader = New OleDbCommand("SELECT * FROM YourTable WHERE YourIDColumn='" & TextBox1.Text & "'", AccessConn).ExecuteReader
                        If DR.HasRows Then
                            DR.Read()
                            MsgBox(DR.GetString(DR.GetOrdinal("Some Column")))
                        Else
                            'Nothing Found
                        End If
                    End Using
                    AccessConn.Close()
                End Using
            End If
        End Sub
    End Class



    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Wednesday, June 20, 2018 2:58 AM