Hi all,
I am Mariya looking for assistance .
How to split barcode ID into few textbox as per attached after press command "ENTER" ? Note: Contains of ID are letter, number, space.
Hi Mariya,
Can you please supply your workbook and code otherwise anything we write will have to be rewritten to suit your environment.
Thx
Phil
Hi Phil,
Thanks for your reply. Attached as below.
You may click "CLICK ME" so that the userform will be pop-up.
Hi Mariya,
Please see attached. Splitting up the code is pretty straightforward using VBA string functions
You could also read my Excel Forms posts to help you learn a bit more
Please note: the code in the workbook will only work if the code is always the same structure, that is, the same length and each of the substrings are the same length and in the same position.
Regards
Phil
Hi Phil,
The code works fine !
I really appreciate your help and read thru the website/forum post as you suggest.
Thanks, Phil 🙂
Glad to help 🙂
FWIW, you could also use a couple of user-defined types, like this:
Private Type theBarcode
theCode As String * 30
End Type
Private Type BarcodeParts
BatchNumber As String * 7
space1 As String * 1
CodeNumber As String * 8
space2 As String * 1
Section As String * 1
space3 As String * 1
RequiredDate As String * 5
Prefix As String * 6
End Type
Private Sub CommandButton1_Click()
Dim BarCode As theBarcode
Dim theParts As BarcodeParts
BarCode.theCode = Range("B9").Value
LSet theParts = BarCode
tbScan.Value = BarCode.theCode
With theParts
BatchNum.Value = .BatchNumber
BatchMonth.Value = Left(.BatchNumber, 4)
Code.Value = .CodeNumber
Section.Value = .Section
RequiredDate.Value = .RequiredDate
Prefix.Value = .Prefix
End With
End Sub