How to: Time-in and time-out status on vb.net <p>`Public Sub updateTextBox()</p> <pre><code> s = s + SerialPort1.ReadExisting() If Len(s) &gt; 12 Then Try txtReceived.Text = Microsoft.VisualBasic.Mid(s, 1, 12) strSql = "SELECT * FROM stud WHERE tag = '" &amp; txtReceived.Text &amp; "';" 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 &gt; 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` </code></pre> <p>Good day! I've been working on an RFID based Daily-Time-Record of a school for our Thesis. My problem is how to set the "status" of the student when he/she 1st tapped the RFID card it should be status = Time-In and when he/she tapped it for the 2nd time the status should be Time-out. Every student has a limit of one Time-In and one Time-out a day. Any idea on how to do this? Hope you guys get what im pointing out.</p>