Part 9: Articles
A49
Part 9: Articles
Article 3
Visual Basic Function
Reference
Finding all the most useful functions in Help can be difficult at best. When you know the
function name you want, you can type it in the Visual Basic Editor, highlight the name, and
then press F1 to go directly to the help topic. Following is a list of functions, categorized by
type, that you might need to use. The tables list the function name and a brief description
of what the function does. You can easily find details about the particular function syntax in
Help once you know the function name.
As you know, you can call most Visual Basic functions from queries that you create in an
Access desktop database (.mdb). If you convert your application to SQL Server, you need
to know the equivalent function or clause you can use to obtain the same result. The
tables also list the SQL Server equivalent for all function types except User Interface/File
System Functions.
Table A3-1.
Arithmetic Functions
Name Description SQL Server Equivalent
Abs Returns the absolute value of a number. ABS
Asc Returns the integer value of a character. ASCII
Atn Returns the arctangent of a number. ATAN
Cos Returns the cosine of a number that is an
angle specified in radians.
COS
DDB Returns a double value containing the depreciation
of a value for a specific time period.
(none)
Exp Returns the value of the base of the natural
logarithm (e) raised to the exponent you supply.
UBound.
(none)
Log Returns the natural logarithm of the number you
supply. See also Exp.
LOG
MIRR Returns the modified internal rate of return for
a series of periodic cash flows.
(none)
NPer Returns the number of payment periods for
an annuity.
(none)
NPV Returns the net present value of an investment. (none)
Pmt Returns the payment required for an annuity. (none)
PPmt Returns the amount applied to principal for a
given payment period of an annuity.
(none)
PV Returns the present value of an annuity. (none)
Rate Returns the interest rate of an annuity. (none)
Rnd Returns a random number. RAND
Round Rounds a number to the specified number of
decimal places.
ROUND
Sin Returns the sine of a number that is an angle
specified in radians.
SIN
SLN Returns the straight-line depreciation of an asset
for a single period.
(none)
Sqr Returns the square root of a number. SQRT
SYD Returns the sum-of-the-years’ digits depreciation
CAST or CONVERT used
with ROUND
CLng Converts a value to Long Integer data type.
The function rounds fractions.
CAST or CONVERT used
with ROUND
CSng Converts a value to Single data type. CAST, CONVERT
CStr Converts a value to a String data type. A Null
value generates an error. Boolean values
convert to yes or no. Dates convert to a string
in your system’s short date format.
CAST, CONVERT
CVar Converts a value to a Variant data type. If the
value is a number, the value must be in the
ranges valid for CDbl.
CAST, CONVERT
Val Converts the numbers found in a string to a
valid numeric data type.
(none)
Chapter A3Chapter A3
Article 3Chapter A3Article 3Chapter A3
Part 9: Articles
Microsoft Office Access 2003 Inside Out
Part 9: Articles
A52
Table A3-3.
Date/Time Functions
Name Description SQL Server Equivalent
Date Returns the current system date as a Variant
data type.
Now Returns the current system date and time as
a Variant data type.
GETDATE
Second Returns the seconds portion of a date/time
value. See also DatePart.
DATEPART
Time Returns the current system time as a Variant
data type.
CAST or CONVERT with
GETDATE
Timer Returns a Double data type containing the
number of seconds elapsed since midnight,
accurate to .01 seconds.
(none)
Part 9: Articles
Chapter A3Chapter A3Article 3Chapter A3Article 3Chapter A3
Visual Basic Function Reference
A53
Part 9: Articles
TimeSerial Returns a time value calculated from supplied
integer hour, minute, and second values.
CAST, CONVERT
TimeValue Returns the time portion of a date/time value. CAST, CONVERT
WeekDay Returns the integer day of the week from a
date/time value. Sunday is 1, Monday is 2,
and so on.
DATEPART or DATENAME
with CASE
WeekDayName Returns the name of the day from a date/time
value.