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

Numberformat (easy one I guess)

P: n/a
I have a number as integer in a database.

When I select it and present it in a label I want it to show as 4
characters.

Example 1:
From the database I get the value 22
I want to present it as 0022

Example 2:
From the database I get the value 235
I want to present it as 0235

Thanx/
Lars
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try:

Dim i as Integer = CType(myDataReader("myField"), Integer)
dim s as string = i.tostring("0000")
----- Lars Netzel wrote: -----

I have a number as integer in a database.

When I select it and present it in a label I want it to show as 4
characters.

Example 1:
From the database I get the value 22
I want to present it as 0022

Example 2:
From the database I get the value 235
I want to present it as 0235

Thanx/
Lars

Nov 20 '05 #2

P: n/a
Hi Lars

You can try the format function

Synta

Format(<the number which you want to format>,"000000") ' no of Zeros in the second argument represents the length and what characters need to be filled for the remaining characters.

for example

MsgBox(Format(10, "0000")

displays 0010 in the message box

Is that not simple

Sadha Sivam
Malleable Minds Software Pvt Ltd.,
Nov 20 '05 #3

P: n/a
thanx!

/lars

"Sadha Sivam S" <sa************@yahoo.com> skrev i meddelandet
news:DD**********************************@microsof t.com...
Hi Lars,

You can try the format function.

Syntax

Format(<the number which you want to format>,"000000") ' no of Zeros in the second argument represents the length and what characters need to be
filled for the remaining characters.
for example,

MsgBox(Format(10, "0000"))

displays 0010 in the message box.

Is that not simple.

Sadha Sivam S
Malleable Minds Software Pvt Ltd.,

Nov 20 '05 #4

P: n/a
Hi,

this should help I guess

lblFormat.Text = Format(CInt(txtFormat.Text), "0000")

make sure the value you want to format is a integer otherwise it won't work

greetz

"Lars Netzel" <la*********@qlogic.se> wrote in message news:<eQ**************@TK2MSFTNGP09.phx.gbl>...
I have a number as integer in a database.

When I select it and present it in a label I want it to show as 4
characters.

Example 1:
From the database I get the value 22
I want to present it as 0022

Example 2:
From the database I get the value 235
I want to present it as 0235

Thanx/
Lars

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.