C
chris_gpf1
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
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