DateDiff Function
DateDiff Function
The DateDiff function returns the intervals between two dates in terms of years, months
or days. The syntax for this is given below.
DateDiff (interval, date1, date2[, firstdayofweek[, firstweekofyear]])
Format Function
The format function accepts a numeric value and converts it to a string in the format
specified by the format argument. The syntax for this is given below.
Format (expression[, format[, firstdayofweek[, firstweekofyear]]])
The Format function syntax has these parts:
Part Description
Expression Required any valid expression
format Optional. A valid named or user-defined format expression.
firstdayofweek Optional. A contant that specifies the first day of the week.
Procedurename = …
End Function
A subprocedure or function may be created from the "Tools" menu or simply typed in in
the (General) section of the code page. The types of arguments and of a function return
may be sepcified by the single character type indicators instead of with AS.
Just as clicking on a command button generates an event that starts the execution of
the appropriate event handler, the statement
Call Procedurename
If there are no arguments, or
Call Procedurename( arguments )
If there are arguments starts the execution of the subprocedure. Once the subprocedure
has run, execution continues at the statement after the call. The number of arguments
in the call should match the number of arguments in the declaration, and while Basic will
do some conversions automatically, it is best if the types match as well.
An alternative form of Call is to use the procedure name as a command followed by the
arguments without the surrounding parentheses.
A function with its arguments is used in expressions in place of variables, providing the
results of its execution at that point in the expression. For example if we have a
command button, Command1, two text boxes for numeric input, Text1 and text2 and a
picture box for output, we can apply the Pythagorean theorem with:
Picture1.Cls
Picture1.Print hypotenuse(Val#(Text1.Text),Val#(Text2.Text))
End Sub
We have used the built-in function Sqr. There are several useful built-in functions, some
of which are given in the following table: