'公用Sub updateTextBox()如何:時間在和超時狀態上vb.net
s = s + SerialPort1.ReadExisting()
If Len(s) > 12 Then
Try
txtReceived.Text = Microsoft.VisualBasic.Mid(s, 1, 12)
strSql = "SELECT * FROM stud WHERE tag = '" & txtReceived.Text & "';"
command.CommandText = strSql
command.Connection = SQLConnection
datapter.SelectCommand = command
datardr = command.ExecuteReader
Dim img() As Byte
If datardr.HasRows Then
datardr.Read()
img = datardr("picture")
Dim ms As New MemoryStream(img)
txtFname.Text = datardr("fname").ToString
txtLname.Text = datardr("lname").ToString
PictureBox1.Image = Image.FromStream(ms)
SQLConnection.Close()
End If
SQLConnection.Open()
Catch ex As Exception
End Try
Try
Dim i As Integer
Dim newtag As Boolean = True
Dim stringfix As String
Dim string1 As String
Dim string2 As String
For i = 0 To (grid.Rows.Count - 1)
stringfix = grid.Rows.Item(i).Cells(0).Value
string1 = Microsoft.VisualBasic.Mid(stringfix, 1, 10)
string2 = Microsoft.VisualBasic.Mid(stringfix, 2, 10)
If string1 = string2 Then
newtag = False
Exit For
Else
newtag = True
End If
Next
If newtag = True Then
Dim dr As Integer
dr = grid.Rows.Add()
grid.Rows.Item(dr).Cells.Item(0).Value = Microsoft.VisualBasic.Mid(s, 1, 12)
grid.Rows.Item(dr).Cells(1).Value = txtFname.Text
grid.Rows.Item(dr).Cells(2).Value = txtLname.Text
grid.Rows.Item(dr).Cells.Item(3).Value = txtDate.Text + " " + txtTime.Text
grid.Rows.Item(dr).Cells.Item(4).Value = "TIME IN"
ElseIf newtag = False Then
grid.Rows.Item(i).Cells.Item(3).Value = txtDate.Text + " " + txtTime.Text
grid.Rows.Item(i).Selected = True
End If
Catch ex As Exception
End Try
Dim timeOut As DateTimeOffset = Now.AddMilliseconds(1500)
Do
Application.DoEvents()
Loop Until Now > timeOut
s = SerialPort1.ReadExisting()
SerialPort1.DiscardOutBuffer()
s = String.Empty
SerialPort1.DtrEnable = True
txtReceived.Text = ""
txtFname.Text = ""
txtLname.Text = ""
PictureBox1.Image = Nothing
End If
End Sub`
美好的一天!我一直在爲我們的論文研究一所學校的基於RFID的日常時間記錄。我的問題是如何設置學生的「狀態」,當他/她第一次點擊RFID卡時,它應該是status = Time-In,當他/她第二次點擊它時,狀態應該是超時。每個學生每天有一次Time-In和一次Time-out限制。任何想法如何做到這一點?希望你們能得到我指出的內容。
您需要提供更多信息並希望獲得一些代碼。你有什麼嘗試?你使用的是數據庫還是硬編碼的「學生」?爲每個學生記錄一個計數器並不困難,所以這個問題相當廣泛。 – TheValyreanGroup
這實際上只是一個非常寬泛的規範 - 它並不適用於堆棧溢出問答格式。另外 - 如果一個學生刻下他人的卡片並敲出來,每天限制1次,他們現在是否會陷入麻煩? –
@TheValyreanGroup是的,我正在使用數據庫。我該怎麼處理櫃檯?對不起,問我,剛剛對RFID和vb.net新希望你們明白。我將加上一些我使用的代碼。這段代碼的進展是它可以從數據庫中檢索數據。不介意DataGrid。我只是不知道該怎麼做才能在狀態中進行暫停和超時。 –