9 digits no matter what

  • Thread starter Thread starter Drygast
  • Start date Start date
D

Drygast

I've got an application where I enter ordernumbers through a barcodereader.
I would like to have the application save 9 digits to the accessdatabase no
matter how few digits is entered.
For instance if I enter: 12345678 I would like to "pad" a 0 on the lefthand
side making sure 9 digits is saved.

Is it possible and do I need to do something with the accessdatabase? (The
field I use in the database is of "number"-type)'

Regards
/Drygast
 
Hi,

You are going to have to save the padded number as a string in the
access database if you want the zeros.

Dim x As Integer = 25

Me.Text = x.ToString("00000000#")

Ken
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim MyStr As String

MyStr = Microsoft.VisualBasic.Format(334, "000000000")

MessageBox.Show(MyStr)

End Sub

Cheers - OHM
 
Drygast said:
I've got an application where I enter ordernumbers through a
barcodereader. I would like to have the application save 9 digits to
the accessdatabase no matter how few digits is entered.
For instance if I enter: 12345678 I would like to "pad" a 0 on the
lefthand side making sure 9 digits is saved.

Is it possible and do I need to do something with the accessdatabase?
(The field I use in the database is of "number"-type)'

If you need to keep leading zeros, the database field must be defined as
text. To add missing leading zeros, you can use


MsgBox(12345.ToString("000000000"))
 
Drygast,
If the number entered are in integer variables, you can use:

Dim x As Integer = 25

Me.Text = x.ToString("D9")

In addition to:

Me.Text = x.ToString("00000000#")

and the other formats discussed.

Hope this helps
Jay
 
Back
Top