Hi,
I am using Serial Controller to get the output into a listbox form a weighing scale machine,
I put two button with the same code in Data Available Event
while me.BytesAvailable > 0
dim s as string = me.ReadAll
Listbox1.AddRow s
me.poll
wend
the problem is , when I press the button 1 to receive the output, is working.
but it wont work for the second button press
Button 1 code (worked)
l_input.text="Auto"
lkt.Text="1"
Listbox1.DeleteAllRows
dim g as new date
txtjam_masuk.text=""
txtjam_masuk.text=str(g.ShortTime)
If Me.Caption = "Stop" Then // Disconnect from the serial port
SerialController.Close
Me.Caption = "KG"
SerialPortsPopupMenu.Enabled = True
PortListUpdater.Mode = Timer.ModeMultiple // turn the PortListUpdater timer back on
Else // Connect to the serial port
SerialController.SerialPort = System.SerialPort(SerialPortsPopupMenu.ListIndex) // Set the serial port to the index of the one chosen in the popup menu
If SerialController.Open Then
Me.Caption = "Stop"
SerialPortsPopupMenu.Enabled = False
PortListUpdater.Mode = Timer.ModeOff
Else
Beep
Label1.text="The selected serial port could not be opened."
End If
End If
if cmbStatus.ListIndex=1 then 'kirim
dim a,b,c as double
a=CDbl(Label9.text)
b=CDbl(Label2.text)
c=a-b
label11.text= Format(c , "###,##0")
dim a1,b1,c1 as Double
a1=CDbl(label11.text)
b1=CDbl(txtpalet.text)
c1=a1-b1
label24.text= Format(c1 , "###,##0")
end if
if cmbStatus.ListIndex=2 then 'terima
dim a,b,c as double
a=CDbl(Label9.text)
b=CDbl(Label2.text)
c=b-a
label11.text= Format(c , "###,##0")
dim a1,b1,c1 as Double
a1=CDbl(label11.text)
b1=CDbl(txtpalet.text)
c1=a1-b1
label24.text= Format(c1 , "###,##0")
end if
if btnbatal.text="1" then
Update_data
end if
if cmbStatus.ListIndex=0 then
label1.Text="Silahkan pilih statusnya, kirim apa terima"
else
label1.Text="Connected to local server"
end if
and this the button 2 code,
l_input.text="Auto"
lkt.Text="2"
Listbox1.DeleteAllRows
dim g as new date
txtjam_keluar.text=""
txtjam_keluar.text=str(g.ShortTime)
If Me.Caption = "Stop" Then // Disconnect from the serial port
SerialController.Close
Me.Caption = "KG"
SerialPortsPopupMenu.Enabled = True
PortListUpdater.Mode = Timer.ModeMultiple // turn the PortListUpdater timer back on
Else // Connect to the serial port
SerialController.SerialPort = System.SerialPort(SerialPortsPopupMenu.ListIndex) // Set the serial port to the index of the one chosen in the popup menu
If SerialController.Open Then
Me.Caption = "Stop"
SerialPortsPopupMenu.Enabled = False
PortListUpdater.Mode = Timer.ModeOff
Else
Beep
Label1.text="The selected serial port could not be opened."
End If
End If
if cmbStatus.ListIndex=1 then 'kirim
dim a,b,c as double
a=CDbl(Label9.text)
b=CDbl(Label2.text)
c=a-b
label11.text= Format(c , "###,##0")
dim a1,b1,c1 as Double
a1=CDbl(label11.text)
b1=CDbl(txtpalet.text)
c1=a1-b1
label24.text= Format(c1 , "###,##0")
end if
if cmbStatus.ListIndex=2 then 'terima
dim a,b,c as double
a=CDbl(Label9.text)
b=CDbl(Label2.text)
c=b-a
label11.text= Format(c , "###,##0")
dim a1,b1,c1 as Double
a1=CDbl(label11.text)
b1=CDbl(txtpalet.text)
c1=a1-b1
label24.text= Format(c1 , "###,##0")
end if
if btnbatal.text="1" then
Update_data
end if
if cmbStatus.ListIndex=0 then label1.Text="please select the status"
any help ?
thanks
regards,
Arief