Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 56 characters in body
Source Link
Mark Ismail
  • 720
  • 4
  • 9
  • 22

This answer will handle any fast typing.

Dim scanner_input As Boolean = False Dim start_typing As DateTime Private Sub TextBox_part_number_TextChanged(sender As Object, e As EventArgs) Handles TextBox_part_number.TextChanged If (TextBox_part_number.Text.Length = 1) Then start_typing = DateTime.Now scanner_input = False '' MsgBox(start_typing.ToString) ElseIf (TextBox_part_number.Text.Length > 7) Then If (calc_typing_time(start_typing) < 1500) Then scanner_input = True Else scanner_input = False End If End If End Sub Function calc_typing_time(time_started As DateTime) Dim time_finished As DateTime time_finished = DateTime.Now Dim duration As TimeSpan = time_finished - time_started Dim time_diff As String = duration.SecondsTotalMilliseconds Return time_diff End Function 
Dim scanner_input As Boolean = False Dim start_typing As DateTime Private Sub TextBox_part_number_TextChanged(sender As Object, e As EventArgs) Handles TextBox_part_number.TextChanged If (TextBox_part_number.Text.Length = 1) Then start_typing = DateTime.Now scanner_input = False '' MsgBox(start_typing.ToString) ElseIf (TextBox_part_number.Text.Length > 7) Then If (calc_typing_time(start_typing) < 1) Then scanner_input = True Else scanner_input = False End If End If End Sub Function calc_typing_time(time_started As DateTime) Dim time_finished As DateTime time_finished = DateTime.Now Dim duration As TimeSpan = time_finished - time_started Dim time_diff As String = duration.Seconds Return time_diff End Function 

This answer will handle any fast typing.

Dim scanner_input As Boolean = False Dim start_typing As DateTime Private Sub TextBox_part_number_TextChanged(sender As Object, e As EventArgs) Handles TextBox_part_number.TextChanged If (TextBox_part_number.Text.Length = 1) Then start_typing = DateTime.Now scanner_input = False '' MsgBox(start_typing.ToString) ElseIf (TextBox_part_number.Text.Length > 7) Then If (calc_typing_time(start_typing) < 500) Then scanner_input = True Else scanner_input = False End If End If End Sub Function calc_typing_time(time_started As DateTime) Dim time_finished As DateTime time_finished = DateTime.Now Dim duration As TimeSpan = time_finished - time_started Dim time_diff As String = duration.TotalMilliseconds Return time_diff End Function 
Source Link
Mark Ismail
  • 720
  • 4
  • 9
  • 22

Dim scanner_input As Boolean = False Dim start_typing As DateTime Private Sub TextBox_part_number_TextChanged(sender As Object, e As EventArgs) Handles TextBox_part_number.TextChanged If (TextBox_part_number.Text.Length = 1) Then start_typing = DateTime.Now scanner_input = False '' MsgBox(start_typing.ToString) ElseIf (TextBox_part_number.Text.Length > 7) Then If (calc_typing_time(start_typing) < 1) Then scanner_input = True Else scanner_input = False End If End If End Sub Function calc_typing_time(time_started As DateTime) Dim time_finished As DateTime time_finished = DateTime.Now Dim duration As TimeSpan = time_finished - time_started Dim time_diff As String = duration.Seconds Return time_diff End Function