串口 窗口 扫码开始 按钮代码
e.Form.Controls("TextBox11").Value = Nothing '清空原先数据
forms("串口").Controls("TextBox11").Select '定位到录入位置
Ports.Add("COM4") '开启
Ports("COM4").Open() '打开串口
Dim hexa(3) As Byte
hexa(0)=&H16
hexa(1)=&H54
hexa(2)=&H0d
Ports("COM4").Write(hexa,0,3)
If Tables("表A").Current IsNot Nothing Then '先判断是否有行
For i As Integer = CurrentTable.TopPosition To CurrentTable.BottomPosition
CurrentTable.Rows(i)("开始时间") = now() '赋值当前时间
Next
End If
Tables("表A").save '保存
去掉扫码结束按钮,结束时间放到DataReceived事件处理
设备监视器 DataReceived事件代码
Forms("串口").Controls("TextBox11").Text = e.Port.ReadExisting() '获取数据
'MessageBox.Show("控件接收到数据")
Dim btn As WinForm.Button = Forms("串口").Controls("单号查询") ''''获取新的数据后进行查询动作
btn.PerformClick()
If Tables("表A").Current IsNot Nothing Then '先判断是否有行
For i As Integer = CurrentTable.TopPosition To CurrentTable.BottomPosition
CurrentTable.Rows(i)("结束时间") = now() '赋值当前时间
Next
End If
'MessageBox.Show("执行查询")