Takto čtu data za čtečky: Dim myPort As Array 'COM Ports detected on the system will be stored here Delegate Sub SetTextCallback(ByVal [text] As String) tohle pod sebou skrývá tlačítko: Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Button8.Enabled = True rtbreceived.Text = "" SerialPort1.Close() ' Pokud port zůstal otevřen tak jej zavře SerialPort1.PortName = "COM10" 'Set SerialPort1 to the selected COM port at startup SerialPort1.BaudRate = "9600" 'Set Baud rate to the selected value o 'Other Serial Port Property SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.DataBits = 8 'Open our serial port SerialPort1.Open() Timer1.Enabled = True ' Po přijmutí dat ze čtečky port zavře End Sub Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived ReceivedText(SerialPort1.ReadExisting()) 'Automatically called every time a data is received at the serialPort End Sub Private Sub ReceivedText(ByVal [text] As String) 'compares the ID of the creating Thread to the ID of the calling Thread If Me.rtbreceived.InvokeRequired Then Dim x As New SetTextCallback(AddressOf ReceivedText) Me.Invoke(x, New Object() {(text)}) Else Me.rtbreceived.Text &= [text] Label1.Text = "ČIP NAČTEN" Button8.Enabled = False Timer1.Enabled = True Label12.Text = sec End If End Sub a nakonec timer který zajistí 100 % zavření portu a spuštění ověřování Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick sec = sec + 0 Label12.Text = sec If Label12.Text = "0" Then Timer1.Stop() Label12.Text = "0" sqaccess() SerialPort1.Close() End If sec = 0 End Sub
|