## VB6 Tutorial 34: Handy Numeric functions

Posted On 2018-04-18 by VB6Boy
Keywords:
Tags: VB6 Tutorials Windows
Views: 35

Looking for the more of the VB6 Tutorial? Here is the tutorial index.

In this lesson, we'll take a look at three numeric functions: SQR, INT, and Round. In a later lesson, we'll take a look at more numeric functions.

### The Sqr function

The Sqr function returns the square root of a number. This function takes a Double type argument and returns a Double implying that you can work with large numbers using the Sqr function.

#### Example

`Print Sqr(9)`

Output: 3

### The Int function

The Int function returns the greatest integer less than or equal to the number. It discards the decimal part of a number. This function greatly helps in truncating the decimal part of a number. But be aware that in case of a negative decimal number, it returns a rounded up value, resulting in an increment of integer part as it's shown in example 3 below.

#### Example

`Print Int(2.9)`

Output: 2

#### Example

`Print Int(5)`

Output: 5

#### Example 3

`Print Int(-5.8)`

Output: -6

### The Round function

The Round function rounds a numeric value.

#### Syntax

`Round(Number, [no. of digits after decimal]`

If the second parameter is omitted, the number is rounded to a whole number.

#### Example

`Print Round(5.8)`

Output: 6

#### Example

`Print Round(5.8, 1)`

Output: 5

#### Example

`Print Round(5.4568, 2)`

Output: 5.46

Later in the series, we'll take a look at more numeric functions.

Looking for the more of the VB6 Tutorial? Here is the tutorial index.

has posted a total of 78 articles.

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.