3rdElement

08-03-2005, 12:13 AM

I am getting value of 40833.0 displaying in my VB textbox, generating from another program. Now I wanted to move decimal at -3, turning it into 40.8. How do I do this with VB code?

I tried divididng by 1000 and I get round off to 41.0... Actually I want precise number "40.8. Anyone?

this is the code string

CurValue = 6122 * 6.67 = 40833.0 ---> wanted 40.8

TeraBlight

08-03-2005, 12:17 AM

Try Round() (http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctRound.asp)

3rdElement

08-03-2005, 12:33 AM

Try Round() (http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctRound.asp)

I don't get it! I keep getting error.

TeraBlight

08-03-2005, 01:16 AM

Round Function

Description - Returns a number rounded to a specified number of decimal places.

Syntax - Round(expression [,numdecimalplaces])

expression - Required. Numeric expression being rounded.

numdecimalplaces - Optional. Number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function.

3rdElement

08-03-2005, 01:24 AM

Round Function

I understand what it means, but I don't understand how to implement it with string that I previously posted.

Round(CurValue = 6122 * 6.67, 0.0)

Text1.Text = format(CurValue, "0.0"

I get error...

stevo

08-03-2005, 01:31 AM

because you are assigning the sum to your variable inside the function.

CurValue = 6122 * 6.67

MsgBox Round(CurValue / 1000, 1)

3rdElement

08-03-2005, 01:43 AM

because you are assigning the sum to your variable inside the function.

CurValue = 6122 * 6.67

MsgBox Round(CurValue / 1000, 1)

Thank you!