Saturday, December 26, 2009

Mathematical Functions


Function Name: Int, Fix
Function Description: Returns the Integer portion of the numerical value passed to it.
Common Uses: Int or Fix are used when you wish to convert a numerical value to an integer without regard for the decimal value. It performs a truncation of the number.
Syntax: Integer = Int(Numerical Value)
  Integer = Fix(Numerical Value)

For e.g. Int(199.11) returns 199.

Miscellaneous Functions
Function Name: IsNumeric
Function Description: Returns True if the value passed to it evaluates to a numeric data type, otherwise it returns False.

Common Uses: IsNumeric can be used to verify that a value can be evaluated as a number. Instead of possibly getting either inaccurate results or a run-time error, by using IsNumeric, a proactive approach to error handling can be achieved.
Syntax: Boolean = IsNumeric(Expression)

For e.g. IsNumeric(“ABC”)

Function Name: IsDate
Function Description: Returns True if the value passed to it evaluates to a valid Date, otherwise it returns False.
Common Uses: IsDate can be used when you are about to convert a value to a Date representation. 
Instead of possibly getting either inaccurate results or a run-time error, by using IsDate, a proactive approach to error handling can be achieved.
Syntax: Boolean = IsDate(Expression)

for e.g. IsDate(“January 1, 2001”) 


Function Name: Today

Function Description: Returns the current system date.
Common Uses: Today can be used anytime the developer wishes to access the system date. 
While it is returned as a variant, it can be used as a native date format or converted to a String representation.
Syntax: Date = Today()
Examples:
'Code to display Yesterday’s Date in a MessageBox
Dim dteToday As Date
Dim dteYesterday As Date
Dim strYesterday As String

dteToday = Today()
dteYesterday = DateAdd(DateInterval.Day, -1, dteToday)
strYesterday = CStr(dteYesterday)
MsgBox(strYesterday)
Function Name: TimeOfDay
Function Description: Returns the current system time.
Common Uses: TimeOfDay can be used anytime the developer wishes to access the system time. 
While it is returned as a variant, it can be used as a native date format or converted to a String representation. 
You can store a Time in the DateTime data type.
Syntax: DateTime = TimeOfDay()
Examples:
'Code to display the time now in a MessageBox
Dim dteExactTime As DateTime
dteExactTime = TimeOfDay()
MsgBox(dteExactTime.ToString())
Function Name: Rnd
Function Description: Returns a pseudo random decimal number that is greater than or equal to 0 and less than 1. 
By passing Rnd an optional numeric parameter, you can further control the type of random number you generate.
Common Uses: Random numbers are required for a great many reasons. 
By combining the output of the Rnd function with some basic mathematics, random numbers can be generated within a given range.
Syntax: Variant = Rnd()
Examples:
Function Name: Rnd
Function Description: Returns a pseudo random decimal number that is greater than or equal to 0 and less than 1. 
By passing Rnd an optional numeric parameter, you can further control the type of random number you generate.
Common Uses: Random numbers are required for a great many reasons. 
By combining the output of the Rnd function with some basic mathematics, random numbers can be generated within a given range.
Syntax: Variant = Rnd()
Examples:

Function Name: Format
Function Description: Returns a String representation of the expression passed formatted according to instructions passed to it in the second parameter. Format may be used to improve the appearance of numbers, dates, times, or string values.
Common Uses: Format is used anytime the user needs to beautify the output of a value.Syntax: String = Format(Expression, String)

No comments:

Post a Comment