Gopal
Gopal

Reputation: 11982

Adding a number with zero's

Using VB.Net

When i add a the number with zeros means, it is showing exact result without zero's

For Example

Dim a, b, c as int32

a = 001
b = 5
c = a + b

a = 009
b = 13
c = a + b

Showing output as 6 instead of 006, 22 instead of 022

Expected output

006
022

How to do this.

Need vb.net code help

Upvotes: 0

Views: 269

Answers (2)

Mark Byers
Mark Byers

Reputation: 838326

You need to store a number as a string if you want to store the exact number of zeros. Then addition won't work though.

If you just want to display the number with 3 digits, you can store it as an integer and format the result when you print it.

c.ToString("D3")

Upvotes: 3

Ole
Ole

Reputation: 794

zero is nothing.. If you do a regular mathematical calculation of 001 + 5 the result is still 6. I would suggest you check out string padding.

Upvotes: 0

Related Questions