Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

 

MW Server:

Free Visual BASIC Newsletter

Sections

Features

Tips

Question & Answers

Discussion Board

Sample Code

Newsletters

Products

ActiveX

Cool Links

MW Software

Visual BASIC Land

Questions & Answers


Here you will find questions with there solutions. Post your questions to qa@mwe.8m.com

Rounding Numbers

Question:

Hi, i have a variable (numeric) that i need to round off (i would even be content just to shave off the extra numbers) so that it will only have two decimal places. i.e. now it is like 1234.5678690 and i want it to be 1234.56 (or if i can get it to round) 1234.57

Solution:

This can be easily done by using the following function:

Function RoundNumber(lNumber, Optional iDecimalPlaces As Integer = 1)
    RoundNumber = Int(lNumber * (10 ^ iDecimalPlaces) + 0.5) / (10 ^ iDecimalPlaces)
End Function


Copyright © 1999 MW Software, Inc.
All Rights Reserved.