| ||||||||||||
|
Cos Function
Davg Function
|
VBA Functions for Access
The Visual Basic Cos function takes an angle as an argument and returns the
ratio of 2 sides of a right triangle (the Cosine). The ratio is the length of
the side adjacent to the angle divided by the length of the hypotenuse. The result returned are in the range -1.0 to 1.0 Example:
Dim TheAngle, TheSecant The result of the Cos calculation is 0.26749....
VBA CreateObject Function Example:
' Declare an object variable to hold the object The Visual
Basic CurDir function returns the current default path. Example:
Dim ThePath
Example:
Function Figure_Age(BDate)
Else
The VB Date function returns a variant variable containing the current computer
system date value.
Example:
Msgbox "Today's Date is " & Date
Result: Today's Date is 12/12/2006
The Visual Basic DateAdd function allows you to add a time interval to a
specified date.
Syntax: DateAdd(interval, number, date)
Here are the VB interval definitions:
Interval
Interval Description
Example usage:
MsgBox DateAdd("d", 13, "12/12/2006")
Above VB dateadd examples displays ' 12/25/2006 '
The VB DateDiff function returns a variant variable result of subtracting two
dates. The unit of measure is defined in the interval argument.
Syntax
Arguments:
interval - Required. String expression that is the interval of time you
use to calculate the difference between date1 and date2. See a list of valid
intervals in the
DateAdd function above.
Example:
MsgBox DateDiff("yyyy", "01/01/2005", "11/11/2006")
Above displays '1'.
The VBA DatePart function give you the ability to extract part of a date
constant of variable from a regular calendar date. The part you select is
called the interval and the intervals are the same as
DateAdd function
above.
See detailed information on the DatePart function in our Access SQL query
examples -
date/time query page.
The Visual Basic DateSerial function returns the date (variant) for the
specified year, month, and day.
Syntax: DateSerial(year, month, day) Where: (All fields are required) Year - Integer. Number between 100 and 9999, inclusive, or a numeric expression. Month - Integer. Two digit month between 1 and 12. Day - Integer. Two digit day between 1 and 31. The VB DateValue Function converts a string date expression into a date value. The syntax is DateValue(Date) where date is any standard representation of a date.
Below we use the DateValue function to convert a string to a date value. You can
also use date constants or string literals to assign a date to a Variant or Date
variable, for example, MyDate = #12/13/06#. Not sure why this function is
ever used.
|
|
|
|