开发者

Adding a number with zero's

开发者 https://www.devze.com 2023-04-12 03:19 出处:网络
Using VB.Net When i add a the number with zeros means, it is showing exact result without zero\'s For Example

Using VB.Net

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

For Example

Dim 开发者_如何学Goa, 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


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")


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消