Visual Basic  Glossary

 

Fix

This a numeric function that truncate the decimal part of a number and return an integer. For positive number, it is the same as the function Int, but for negative number, Fix return an integer larger than the number. e.g. :  Fix(-5.46)= -5, but Int(-5.46)=-6
For.....Next

This is a looping procedure. Example1: For i=1 to 10

                                                          x=i+1

                                                         Next i

Example 2:            

For i=1 to 100 step 2

      x=i+4

Next i

                 

Function

Use to create user-defined functions. The Format is

                               Function    function_Name(Arg as dataType......)

                                   Statements

                               End Function

Example:

 

                    Pubic Function BMI (h as single, w as single)

                                BMI=w/(h^2)

                    End Function

 

To call the function, just use another variable and assign the function to it like   yourBMI=BMI(x,y), where the values of x and y can be accepted through an InputBox or text boxes.

 

Format

Format is a function that is used to format user-defined output or styles. The general format is  Format(number, "user's format")

 

Example

Explanation

Output

Format(1234.5,"0")

Rounds to a whole number

1234

Format(0.657,"0.0%")

Converts to percentage form with decimal places

65.7%

Format(12345.6789,"#,##0.00")

Rounds to 2 decimal places with separators between thousands

12,345.68

Format(12345.6789,"$#,##0.00")

Shows dollar sign and rounds to 2 decimal places with separators between thousands

$12,345.68

 

   
   

 

 

  [Back to VB Glossary]