Two types of textbox input

  • Thread starter Thread starter s
  • Start date Start date
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
 
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
 
Back
Top