By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,564 Members | 810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,564 IT Pros & Developers. It's quick & easy.

9 digits no matter what

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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

--------------------------

"Drygast" <dr*****@hotmail.com> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #2

P: n/a
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 wrote:
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

Nov 20 '05 #3

P: n/a
"Drygast" <dr*****@hotmail.com> schrieb
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"))
--
Armin
Nov 20 '05 #4

P: n/a
Hi Drygast.

iSomeNumber.ToString.PadLeft (9)

Regards,
Fergus
Nov 20 '05 #5

P: n/a
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

"Drygast" <dr*****@hotmail.com> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #6

P: n/a
Thanks guys, with your help everything now works as I wanted it to!!!!

/Regards
Drygast

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
"Drygast" <dr*****@hotmail.com> schrieb
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"))
--
Armin

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.