### Thread: Find rounding functions VB6.0 ?

1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2010
Posts
131
Rep Power
9

#### Find rounding functions VB6.0 ?

I want to find rounding functions. In VB60. The function can be fulfilled in the for example below

for example:

794.5 = 795

843.4 = 843

245.345 = 245

I used the function: Round(), Int(), Fix() but not.
2. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
289
Rep Power
49
Based on the numbers you provided, you want to round a single precision number to the nearest whole number. The "Int" function simply truncates the result.
Code:
```Private Sub cmdRound_Click()
Text1.Text = Int(Text1.Text + 0.5)
Text2.Text = Int(Text2.Text + 0.5)
Text3.Text = Int(Text3.Text + 0.5)
End Sub```
The same technique can be used for other significant numbers by multiplying or dividing by powers of 10.

J.A. Coutts
3. Originally Posted by couttsj
Based on the numbers you provided, you want to round a single precision number to the nearest whole number. The "Int" function simply truncates the result.
Code:
```Private Sub cmdRound_Click()
Text1.Text = Int(Text1.Text + 0.5)
Text2.Text = Int(Text2.Text + 0.5)
Text3.Text = Int(Text3.Text + 0.5)
End Sub```
The same technique can be used for other significant numbers by multiplying or dividing by powers of 10.

J.A. Coutts
Hi Coutts

apart from multiplying or dividing is their any other formula for this.
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
289
Rep Power
49
Originally Posted by PeterSullivan
Hi Coutts

apart from multiplying or dividing is their any other formula for this.
For single or double precision numbers, you can use the Round function to adjust the number of decimal places. There is no function for rounding numbers to the left of the decimal place.

J.A. Coutts
5. No Profile Picture
Grumpier old Moderator
Devshed Supreme Being (6500+ posts)

Join Date
Jun 2003
Posts
14,561
Rep Power
4550
I don't know if this kb article will be helpful, but it looks to be a pretty complete discussion of rounding and different types of rounding.

http://support.microsoft.com/kb/196652