ASP.Net and Barcode Scanner

Discussion in 'ASP .Net' started by chris_gpf1@hotmail.com, Jul 26, 2007.

  1. Guest

    Hi,
    I'm working on a website where the user will have to scan a barcode
    with a serial barcode scanner.

    I get the scanner working and reading the barcode, but when I want to
    write the string in a Textbox, it's not working. The Textbox remain
    blank.

    Here's the code:


    WithEvents _comPort As New IO.Ports.SerialPort
    Delegate Sub SetValue(ByVal barcode As String)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    ' Initialize the scanner.
    End Sub

    Sub ShowValue(ByVal barcode As String)
    TextBox1.Text = barcode
    End Sub

    Private Sub ReadBarcode(ByVal sender As Object, ByVal e As
    IO.Ports.SerialDataReceivedEventArgs) Handles _comPort.DataReceived

    Dim value As String
    Dim targetMethod As Reflection.MethodInfo =
    Me.GetType().GetMethod("ShowValue")
    Dim deleg As SetValue =
    DirectCast([Delegate].CreateDelegate(GetType(SetValue), Me,
    targetMethod), _
    SetValue)

    value = _comPort.ReadLine
    deleg.Invoke(value)
    End Sub


    Can somebody help me please!
    Thanks

    Chris
     
    , Jul 26, 2007
    #1
    1. Advertising

  2. ThunderMusic Guest

    hi,
    you seem to do everything server side... but I think what you want to
    achieve should be done client-side. imagine if you were to start 2 clients
    connected to the page, which one your server will send the text to? (both?)
    and it would mean the scanner is plugged in your server, which may not be
    what you want.

    I think the solution will be to get the value using javascript... can
    javascript interact with COM ports, not that I know of...

    The solution you may have is to install certain drivers (some serial scanner
    have) so the input from your scanner is translated as if it were typed on
    the keyboard. Then you'd not have to worry anymore about your scanner.

    I hope it helps

    ThunderMusic

    <> wrote in message
    news:...
    > Hi,
    > I'm working on a website where the user will have to scan a barcode
    > with a serial barcode scanner.
    >
    > I get the scanner working and reading the barcode, but when I want to
    > write the string in a Textbox, it's not working. The Textbox remain
    > blank.
    >
    > Here's the code:
    >
    >
    > WithEvents _comPort As New IO.Ports.SerialPort
    > Delegate Sub SetValue(ByVal barcode As String)
    >
    > Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.Load
    > ' Initialize the scanner.
    > End Sub
    >
    > Sub ShowValue(ByVal barcode As String)
    > TextBox1.Text = barcode
    > End Sub
    >
    > Private Sub ReadBarcode(ByVal sender As Object, ByVal e As
    > IO.Ports.SerialDataReceivedEventArgs) Handles _comPort.DataReceived
    >
    > Dim value As String
    > Dim targetMethod As Reflection.MethodInfo =
    > Me.GetType().GetMethod("ShowValue")
    > Dim deleg As SetValue =
    > DirectCast([Delegate].CreateDelegate(GetType(SetValue), Me,
    > targetMethod), _
    > SetValue)
    >
    > value = _comPort.ReadLine
    > deleg.Invoke(value)
    > End Sub
    >
    >
    > Can somebody help me please!
    > Thanks
    >
    > Chris
    >
     
    ThunderMusic, Jul 26, 2007
    #2
    1. Advertising

  3. Guest

    > The solution you may have is to install certain drivers (some serial scanner
    > have) so the input from your scanner is translated as if it were typed on
    > the keyboard. Then you'd not have to worry anymore about your scanner.
    >
    > I hope it helps


    Thanks for the idea!

    Did not found this option in the drivers but I made a program in
    VB.Net that redirect the COMPort Input to keyboard and it's working
    fine!

    Chris
     
    , Jul 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    1,621
    tehka
    Sep 5, 2006
  2. mickyblu
    Replies:
    0
    Views:
    464
    mickyblu
    Jul 6, 2006
  3. Benji York
    Replies:
    0
    Views:
    735
    Benji York
    Oct 11, 2005
  4. inga2005
    Replies:
    1
    Views:
    503
    Louis Somers
    Sep 23, 2008
  5. Chad
    Replies:
    1
    Views:
    158
    dlbjr
    Sep 18, 2003
Loading...

Share This Page