cut the numbers

dezreena

Member
Joined
Mar 29, 2007
Messages
20
Programming Experience
Beginner
hello VB college!

i have question about how can i cut my numbers.. for example

1.
my output: x=4,152
i want it to be: x=4,1520

im using this code:
VB.NET:
label1.text= format(x)

2.
my output: y=3,69515E-002
i want it to be: y=3,6952E-2

im using this code:

VB.NET:
label1.text= format(y.tostring("E"))


Does anyone have idea how to do it ? :confused:
thanks a lot..
 
Don't use the Format function at all.

1.
VB.NET:
label1.Text = x.ToString("n4")
"n4" indicates a normal number with 4 decimal places.

2.
VB.NET:
label1.Text = y.ToString("#.####E+0")
"#.####" indicates up to 4 decimal places. Use "#.0000" if you want exactly 4 decimal places. "+" indicates a sign is always present on the exponent. "0" means a minimum of 1 digit in the exponent. Add another "0" for each additional digit you require.
 
Back
Top