Tải bản đầy đủ (.pdf) (10 trang)

Tài liệu Tổng quan SQL_ Visual Basic Function Reference ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (82.3 KB, 10 trang )

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.


See also Log.
EXP
Fix Returns the value of the number you supply
truncated to an integer. If the number is
negative, Fix returns the first integer that
is greater than or equal to the number.
See also Int.
CAST, CONVERT (to
tinyint, smallint, int,
or bigint)
FV Calculates the future value of an annuity. (none)
Chapter A3Chapter A3
Article 3Chapter A3Article 3Chapter A3
Part 9: Articles
Microsoft Office Access 2003 Inside Out
Part 9: Articles
A50
Int Returns the value of the number you supply trun-
cated to an integer. If the number is negative,
Int returns the first integer that is less than or
equal to the number. See also Fix.
FLOOR
IPmt Returns the interest payment for a given period
of an annuity.
(none)
IRR Returns the internal rate of return for a series of
periodic cash flows.
(none)
LBound Returns the lowest available subscript for the
array and dimension you specify. See also

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

of an asset.
(none)
Tan Returns the tangent of a number that is an angle
specified in radians.
TAN
UBound Returns the highest available subscript for the
array and dimension you specify. See also
LBound.
(none)
Table A3-1.
Arithmetic Functions
Name Description SQL Server Equivalent
Part 9: Articles
Chapter A3Chapter A3Article 3Chapter A3Article 3Chapter A3
Visual Basic Function Reference
A51
Part 9: Articles
Table A3-2.
Conversion Functions
Name Description SQL Server Equivalent
CBool Evaluates an expression and returns True (−1) or
False (0).
CAST, CONVERT
CByte Converts a value to Byte data type. CAST, CONVERT
CCur Converts a value to Currency data type. CAST, CONVERT
CDate Converts a value to Date/Time data type. CAST, CONVERT
CDbl Converts a value to Double data type. CAST, CONVERT
CDec Converts a value to Decimal data type. CAST, CONVERT
CInt Converts a value to Integer data type.
The function rounds fractions.

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.

CAST or CONVERT used
with GETDATE
DateAdd Adds a specified interval to a date value. DATEADD
DateDiff Finds the difference between two date/time
values in the interval you specify.
DATEDIFF
DatePart Returns a requested portion of a date (second,
minute, hour, week, weekday, day, day of year,
month, quarter, or year).
DATEPART
DateSerial Returns a date value calculated from supplied
integer year, month, and day values. The year
value must be between 100 and 9999.
CAST, CONVERT
DateValue Returns the date portion of a date/time value. CAST, CONVERT
Day Returns the numeric day portion of a date/time
value. See also DatePart.
DAY
Hour Returns the hour portion of a date/time value.
See also DatePart.
DATEPART
Minute Returns the minute portion of a date/time
value. See also DatePart.
DATEPART
Month Returns the numeric month portion of a
date/time value. See also DatePart.
MONTH
MonthName Returns the name of the month of a date/time
value.
DATENAME

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.

DATENAME
Year Returns the year portion of a date/time value.
See also DatePart.
YEAR
Table A3-3.
Date/Time Functions
Name Description SQL Server Equivalent

×