I have a multiline text box which is used to enter barcode numbers into. I have a barcode scanner and all the barcodes will end in L2, L3 or L4. Once a barcode is scanned in I need VB to detect either L2, L3 or L4 then go to a new line and repeat.
Any ideas on where I can start to accomplish this?
You can attach to the TextChanged event and check if the last 2 characters in the text string are L2, L3 or L4 and add a newline to the textbox. An issue you might encounter is if the barcode has an imbedded L2, L3, L4 value (such as 3234L423444L2).
'// code to get Scanned BarCode here.
If Not TextBox1.Lines.Length = 0 Then '// check if TextBox contains text.
TextBox1.Text &= vbNewLine & "my Scanned BarCode" '// add new line and BarCode.
TextBox1.Text = "my Scanned BarCode" '// add BarCode.
With the above code, you should not have any "empty" lines in your TextBox.
If txtTapeList.Text.EndsWith("L3") Then
txtTapeList.Text += vbNewLine
What happens is when I scan (or type) a barcode in the text box the cursor jumps to the begining of the line. If you press the down arror key the cursor does move to the new line but it won't do it automatically for some reason.