我有一個從USB徽章閱讀器獲取用戶ID的功能,用於登錄應用程序。 當我運行應用程序時,直到我滑過標記時,纔會出現登錄窗口。 我需要知道是否可以加載窗口,然後開始運行從USB獲取數據的功能。如何在VB中加載窗體窗口後運行一個函數/子?
謝謝:)
Private Sub SerialPort1_DataReceived()
'Threading.Thread.SpinWait(1000)
OpenPort()
If SerialPort1.IsOpen() Then
byteEnd = SerialPort1.NewLine.ToCharArray
'read entire string until .Newline
readBuffer = SerialPort1.ReadLine()
readBuffer = readBuffer.Remove(0, 1)
readBuffer = readBuffer.Remove(8, 1)
WWIDTextBox.AppendText(readBuffer)
End If
End Sub
Private Sub Form1_Activated(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
SerialPort1_DataReceived()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'SerialPort1_DataReceived()
End Sub
是否要在表單上阻止用戶輸入,直到它被滑動,或者您希望表單接受輸入?想必你正在調用阻塞(同步)方法來讀取徽章。徽章閱讀器的API是否提供任何等效的異步方法? –