Two types of textbox input

S

s

Hello,

I want to use this simple VBA to keep recrod of parts. Textbox1 is for
part number and textbox2 is for invoice number, and these are input by
barcode scanner.
But, digits of invoice number has changed so now I have 2 different
types of invoice numbers. For example 1234 and 12340000. I need all
numbers to be four digits. How can I rewrite VBA to do this?

Private Sub CommandButton1_Click()
Dim nextrow As Long
Sheets("sheet1").Activate
nextrow = Application.WorksheetFunction.countA(Range("a:a")) + 1
Cells(nextrow, 1) = textbox1.Text
Cells(nextrow, 2) = textbox2.Text
textbox1.Text = ""
textbox2.Text = ""
textbox1.SetFocus
End Sub

Thank you very much.
David
 
A

Auric__

s said:
I want to use this simple VBA to keep recrod of parts. Textbox1 is for
part number and textbox2 is for invoice number, and these are input by
barcode scanner.
But, digits of invoice number has changed so now I have 2 different
types of invoice numbers. For example 1234 and 12340000. I need all
numbers to be four digits. How can I rewrite VBA to do this?

Private Sub CommandButton1_Click()
Dim nextrow As Long
Sheets("sheet1").Activate
nextrow = Application.WorksheetFunction.countA(Range("a:a")) + 1
Cells(nextrow, 1) = textbox1.Text
Cells(nextrow, 2) = textbox2.Text
textbox1.Text = ""
textbox2.Text = ""
textbox1.SetFocus
End Sub

Integer division, perhaps?
newNum = oldNum \ 10000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top