Numberformat (easy one I guess)

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

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
 
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
 
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.,
 
thanx!

/lars

Sadha Sivam S said:
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.
 
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
 
Back
Top