Docsity

Routines - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

Toggle sidebar
bg1
Built-in Functions - I
•Built in functions are supplied by the environment
VBScript is running in. Thus although these
functions are supplied for ASP or NT O/S scripts
not all VBScript implementations may support all
of the functions.
•Function Categories
–Math
–String
–Date/Time
–Type Conversion
–Misc.
Docsity.com
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Routines - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Built-in Functions - I

Built in functions are supplied by the environmentVBScript is running in. Thus although thesefunctions are supplied for ASP or NT O/S scriptsnot all VBScript implementations may support allof the functions.

Function Categories - Math - String - Date/Time - Type Conversion - Misc.

Built-in Functions - II

Math

Sin(), Cos(), Abs(), Exp()

Sgn(), Round(), Fix(), Eval()

Conversion

There a lots of functions that start with 'c' they arefor converting the variants into a specific type:cInt(), cLng(), cStr(), etc.

Built-in Functions - IV

Date/Time

Date() Returns the current system date. - DateAdd() Returns a date to which a specified timeinterval has been added. - DateDiff() Returns the number of intervals betweentwo dates. - DatePart() Returns the specified part of a given date. - DateSerial() Creates Dates form M, D, Y - Day,Hour, Minute, Second, … (Returns that part of thecurrent time) - Now() current date and time

Built-in Functions - VI

VBScript has many otherbuilt-in functions andcommands.

The CreateObject() function is most oftenused of these.

Dim objXSet objX = CreateObject("Application.Class")

Notice the use of the SET verb here.

User Defined Functions

As with subroutines, you may define your ownfunctions. A good rule for all user definedroutines is the "one entrance, one exit rule".This is especially true of functions.

Code to avoid having errors

Always provide a return value!

Good Function Design

Function GoodFunction(X, Y) dim retret = 0if y <> 0 then ret = x / y end ifGoodFunction = retExit Function End Function Make a return valueInitialize it to something safeBounds check to avoid errorsReturn the value in the function name