• No results found

VBScript V1.0

N/A
N/A
Protected

Academic year: 2021

Share "VBScript V1.0"

Copied!
69
0
0

Loading.... (view fulltext now)

Full text

(1)

VB Script VB Script

1. What is VBScript?

1. What is VBScript? ...44 2. How

2. How does it does it WWork? ork? ...44.. 3.

3. Date/Time Functions Date/Time Functions ...44 4. Conversion Functions 4. Conversion Functions ...55 5. Format Functions 5. Format Functions ...55 6. Math Functions 6. Math Functions ...55 7. Ar

7. Array Functions ray Functions ...66 8. String Func

8. String Functions tions ...66.. 9. Other Functions

9. Other Functions ...77 10. Date / Time Functions Syntax with Example

10. Date / Time Functions Syntax with Example ...88 10.1 W

10.1 Write text : rite text : How to write text How to write text on a page on a page ...88 10.2 10.2 CDACDATE TE ...88 10.3 Date ... 10.3 Date ...99 10.4 10.4 DateAdd DateAdd ...99 10.5 DateDiff 10.5 DateDiff ...1010 10.6 DatePart 10.6 DatePart ...1111 10.7 DateSerial 10.7 DateSerial ...1212 10.8

10.8 DateVDateValue alue ...1313 10.9 Day 10.9 Day ...1313 10.10 FormatDateTime 10.10 FormatDateTime ...1414 10.11 10.11 Hour Hour ...1414 10.12 IsDate 10.12 IsDate ...1414 10.13 Minute 10.13 Minute ...1515 10.14 Month 10.14 Month ...1515 10.15 MonthName 10.15 MonthName ...1616 10.16 Now 10.16 Now ...1616 10.17 Second 10.17 Second ...1616 10.18 Time 10.18 Time ...1717. 10.19 Timer 10.19 Timer ...1717 10.20 TimeSerial 10.20 TimeSerial ...1717 10.21 TimeV

10.21 TimeValue alue ...1818 10.22 10.22 WWeekday eekday ...1818 10.23 W 10.23 WeekdayName eekdayName ...1919 10.24 Y 10.24 Year ear ...1919. 11. Conversion Functions Syntax

11. Conversion Functions Syntax with Example with Example ...2020 11.1 Asc 11.1 Asc ...2020 11.2 CBool 11.2 CBool ...2020 11.3 CBy 11.3 CByte te ...2020 11.4 CCur 11.4 CCur ...2121 11.5 11.5 CDate CDate ...2121 11.6 CDbl 11.6 CDbl ...2222 11.7 Chr 11.7 Chr ...2222 11.8 CInt 11.8 CInt ...2323 11.9 CLng 11.9 CLng ...2323 11.10 CSng 11.10 CSng ...2323

(2)

11.1 11.11 CStr 1 CStr ...2424 11.12 Hex 11.12 Hex ...2424 11.13 Oct 11.13 Oct ...2525 12. Format

12. Format Functions Syntax Functions Syntax with Example with Example ...2626 12.1 FormatCurrency 12.1 FormatCurrency ...2626 12.2 FormatDateTime 12.2 FormatDateTime ...2727 12.3 FormatNumber 12.3 FormatNumber ...2828 12.4 FormatPercent 12.4 FormatPercent ...2929 13. Math Func

13. Math Functions Syntax with Example tions Syntax with Example ...3030 13.1 Abs 13.1 Abs ...3030. 13.2 Atn 13.2 Atn ...3030 13.3 Cos 13.3 Cos ...3030 13.4. Exp 13.4. Exp ...3131 13.5. Hex 13.5. Hex ...3131 13.6 Int 13.6 Int ...3232 13.7 Fix 13.7 Fix ...3333 13.8 Log 13.8 Log ...3333 13.9 Oct 13.9 Oct ...3333 13.10 Rnd 13.10 Rnd ...3434 13.11 13.11 Sgn Sgn ...3535 13.12 Sin 13.12 Sin ...3636 13.13 Sqr 13.13 Sqr ...3636 13.14 13.14 TTan an ...3636 14. Array Functions Syntax with Example

14. Array Functions Syntax with Example ...3737 14.1 Array ... 14.1 Array ...3737 14.2 Filter 14.2 Filter ...3737 14.3 14.3 Is Array Is Array ...3838 14.4 Join 14.4 Join ...3939 14.5 LBound 14.5 LBound ...3939 14.6 Split 14.6 Split ...4040 14.7 UBound 14.7 UBound ...4141 15. String Functions Syntax with Example

15. String Functions Syntax with Example ...4141 15.1 15.1 InStr InStr ...4141 15.2 In Str Rev 15.2 In Str Rev ...4242 15.3 LCase 15.3 LCase ...4343 15.4 Left 15.4 Left ...4444 15.5 Len 15.5 Len ...4444 15.6 Ltrim 15.6 Ltrim ...4545 15.7 RT 15.7 RTrim rim ...4545 15.8 Trim 15.8 Trim ...4545 15.9 Mid 15.9 Mid ...4646 15.10 Replace 15.10 Replace ...4646 15.11 Right 15.11 Right ...4747 15.12 Space 15.12 Space ...4747 15.13 Str Comp 15.13 Str Comp ...4848 15.14 String 15.14 String ...4848 15.15 Str Reverce 15.15 Str Reverce ...4949 15.16 Ucase 15.16 Ucase ...4949. 16. Other Functions Syntax with Example

(3)

16.1 CreateObject 16.1 CreateObject ...4949 16.2 Eval 16.2 Eval ...5050 16.3 GetLocale 16.3 GetLocale ...5050 16.4

16.4 Get Get Object Object ...5151.. 16.5 GetRef ... 16.5 GetRef ...5151 16.6 InputBox 16.6 InputBox ...5151 16.7 IsEmpty 16.7 IsEmpty ...5252 16.8 16.8 IsNull IsNull ...5353 16.9 IsNumaeric 16.9 IsNumaeric ...5353 16.10 IsObject 16.10 IsObject ...5454 16.11 LoadPicture 16.11 LoadPicture ...5454 16.12 MsgBox 16.12 MsgBox ...5555 16.13 RGB ... 16.13 RGB ...5656 16.14 Round 16.14 Round ...5757 16.15 Script

16.15 Script Engine Engine ...5757 16.16

16.16 ScriptEngineBuildVScriptEngineBuildVersion ersion ...5858 16.17 ScriptEngineMajorV

16.17 ScriptEngineMajorVersion Function ersion Function ...5858 16.18 ScriptEngineMinorV

16.18 ScriptEngineMinorVersion Function ersion Function ...5858 16.19

16.19 SetLocate SetLocate ...5858 16.20 TypeName

16.20 TypeName ...5959 16.21

16.21 VVarTarType ype ...6060 17. For Loop Syntax

17. For Loop Syntax ...6161 Repeats a block of statements while a

Repeats a block of statements while a condition is True or until a condition becomescondition is True or until a condition becomes True.

True...6262 18. Do

18. Do While Syntax While Syntax ...6262 19. While

19. While Statement Syntax Statement Syntax ...6363 20. If Then

20. If Then Else Syntax Else Syntax ...6464.. 21.Sub Routine Syntax

21.Sub Routine Syntax ...6666 ... ...6767 22.Function Syntax

(4)

1. What is VBScript? 1. What is VBScript?

• VBScript is a scripting languageVBScript is a scripting language •

• A scripting language is a lightweight programming languageA scripting language is a lightweight programming language •

• VBScript is a light version of Microsoft's programming language VBScript is a light version of Microsoft's programming language VVisual Basicisual Basic 2. How does it Work?

2. How does it Work?

When a VBScript is inserted into a HTML document, the Internet browser will read When a VBScript is inserted into a HTML document, the Internet browser will read thethe HTML and interpret the VBScript. The VBScript can

HTML and interpret the VBScript. The VBScript can be executed be executed immediatelyimmediately, or at , or at aa later event.

later event.

3. Date/Time Functions 3. Date/Time Functions F

Fuunnccttiioonn DDeessccrriippttiioonn CDate

CDate Converts a valid date and time expression to the variant of Converts a valid date and time expression to the variant of  subtype Date

subtype Date Date

Date Returns the current system dateReturns the current system date DateAdd

DateAdd Returns a date to which a specified time interval has beenReturns a date to which a specified time interval has been added

added DateDiff 

DateDiff  Returns the number of intervals between two Returns the number of intervals between two datesdates DatePart

DatePart Returns the specified part of a given dateReturns the specified part of a given date DateSerial

DateSerial Returns the date for a specified year, month, and dayReturns the date for a specified year, month, and day DateValue

DateValue Returns a dateReturns a date Day

Day Returns a number that represents the daReturns a number that represents the day of the monthy of the month (between 1 and 31, inclusive)

(between 1 and 31, inclusive) FormatDateTime

FormatDateTime Returns an expression formatted as a date Returns an expression formatted as a date or timeor time Hour 

Hour  Returns a number that represents the hour of the dayReturns a number that represents the hour of the day (between 0 and 23, inclusive)

(between 0 and 23, inclusive) IsDate

IsDate Returns a Boolean value that indicates if the evaluatedReturns a Boolean value that indicates if the evaluated expression can be converted to a date

expression can be converted to a date Minute

Minute Returns a number that represents the minute of Returns a number that represents the minute of the hour the hour  (between 0 and 59, inclusive)

(between 0 and 59, inclusive) Month

Month Returns a number that represents the month oReturns a number that represents the month of the year f the year  (between 1 and 12, inclusive)

(between 1 and 12, inclusive) MonthName

MonthName Returns the name of a specified monthReturns the name of a specified month  Now

 Now Returns the current system date and timeReturns the current system date and time Second

Second Returns a number that represents the second Returns a number that represents the second of the minuteof the minute (between 0 and 59, inclusive)

(between 0 and 59, inclusive) Time

Time Returns the current system timeReturns the current system time Timer 

Timer  Returns the number of seconds since 12:00 AMReturns the number of seconds since 12:00 AM TimeSerial

TimeSerial Returns the time for a specific hour, minute, and secondReturns the time for a specific hour, minute, and second TimeValue

TimeValue Returns a timeReturns a time Weekday

(5)

(between 1 and 7, inclusive) (between 1 and 7, inclusive) WeekdayName

WeekdayName Returns the weekday name of a specified day of the week Returns the weekday name of a specified day of the week  Year 

Year  Returns a number that represents the year Returns a number that represents the year 

4. Conversion Functions

4. Conversion Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn Asc

Asc Converts the first letter in Converts the first letter in a string to ANSI codea string to ANSI code CBool

CBool Converts an expression to a variant oConverts an expression to a variant of subtype Booleanf subtype Boolean CByte

CByte Converts an expression to a variant oConverts an expression to a variant of subtype Bytef subtype Byte CCur 

CCur  Converts an expression to a variant oConverts an expression to a variant of subtype Currencyf subtype Currency CDate

CDate Converts a valid date and time expression to the variant of Converts a valid date and time expression to the variant of  subtype Date

subtype Date CDbl

CDbl Converts an expression to a variant oConverts an expression to a variant of subtype Doublef subtype Double Chr 

Chr  Converts the specified ANSI code to a character Converts the specified ANSI code to a character  CInt

CInt Converts an expression to a variant oConverts an expression to a variant of subtype Integer f subtype Integer  CLng

CLng Converts an expression to a variant oConverts an expression to a variant of subtype Longf subtype Long CSng

CSng Converts an expression to a variant oConverts an expression to a variant of subtype Singlef subtype Single CStr 

CStr  Converts an expression to a variant oConverts an expression to a variant of subtype Stringf subtype String Hex

Hex Returns the hexadecimal value of a specified number Returns the hexadecimal value of a specified number  Oct

Oct Returns the octal value of a specified number Returns the octal value of a specified number 

5. Format Functions

5. Format Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn FormatCurrency

FormatCurrency Returns an expression formatted as a currency valueReturns an expression formatted as a currency value FormatDateTime

FormatDateTime Returns an expression formatted as a date Returns an expression formatted as a date or timeor time FormatNumber 

FormatNumber  Returns an expression formatted as a number Returns an expression formatted as a number  FormatPercent

FormatPercent Returns an expression formatted as a percentageReturns an expression formatted as a percentage

6. Math Functions

6. Math Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn Abs

Abs Returns the absolute value of a specified number Returns the absolute value of a specified number  Atn

Atn Returns the arctangent of a specified number Returns the arctangent of a specified number  Cos

Cos Returns the cosine of a specified nuReturns the cosine of a specified number (angle)mber (angle) Exp

Exp ReturnsReturns ee raised to a power raised to a power  Hex

Hex Returns the hexadecimal value of a specified number Returns the hexadecimal value of a specified number  Int

Int Returns the integer part of a specified nReturns the integer part of a specified number umber  Fix

Fix Returns the integer part of a specified nReturns the integer part of a specified number umber  Log

(6)

Oct

Oct Returns the octal value of a specified number Returns the octal value of a specified number  Rnd

Rnd Returns a random number less than 1 but greater or equal to 0Returns a random number less than 1 but greater or equal to 0 Sgn

Sgn Returns an integer that indicates the sign of a specifiedReturns an integer that indicates the sign of a specified number 

number  Sin

Sin Returns the sine of a specified number (angle)Returns the sine of a specified number (angle) Sqr 

Sqr  Returns the square root of a specified nReturns the square root of a specified number umber  T

Tanan Returns the tangent of a specified number (angle)Returns the tangent of a specified number (angle)

7. Array Functions

7. Array Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn Array

Array Returns a variant containing an arrayReturns a variant containing an array Filter 

Filter  Returns a zero-based array that contains a subset of a stringReturns a zero-based array that contains a subset of a string array based on a filter criteria

array based on a filter criteria IsArray

IsArray Returns a Boolean value that Returns a Boolean value that indicates whether a specifiedindicates whether a specified variable is an array

variable is an array Join

Join Returns a string that consists of a number of substrings in anReturns a string that consists of a number of substrings in an array

array LBound

LBound Returns the smallest subscript for the indicated dimension of Returns the smallest subscript for the indicated dimension of  an array

an array Split

Split Returns a zero-based, one-dimensional array that contains aReturns a zero-based, one-dimensional array that contains a specified number of substrings

specified number of substrings UBound

UBound Returns the largest subscript for the indicated dimension of Returns the largest subscript for the indicated dimension of  an array

an array

8. String Functions

8. String Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn InStr 

InStr  Returns the position of the first occurrence of one Returns the position of the first occurrence of one stringstring within another. The search begins at the first character of the within another. The search begins at the first character of the string

string InStrRev

InStrRev Returns the position of the first occurrence of one Returns the position of the first occurrence of one stringstring within another. The search begins at the last character of the within another. The search begins at the last character of the string

string LCase

LCase Converts a specified string to lowercaseConverts a specified string to lowercase Left

Left Returns a specified number of characters from the left side of Returns a specified number of characters from the left side of  a string

a string Len

Len Returns the number of characters in a stringReturns the number of characters in a string LTrim

LTrim Removes spaces on the left side of a stringRemoves spaces on the left side of a string RTrim

RTrim Removes spaces on the right side of a stringRemoves spaces on the right side of a string Trim

Trim Removes spaces on both the Removes spaces on both the left and the right side of a left and the right side of a stringstring Mid

(7)

Replace

Replace Replaces a specified part of a string with another string aReplaces a specified part of a string with another string a specified number of times

specified number of times Right

Right Returns a specified number of characters from the right sideReturns a specified number of characters from the right side of a string

of a string Space

Space Returns a string that consists of a specified number of spacesReturns a string that consists of a specified number of spaces StrComp

StrComp Compares two strings and returns a value that Compares two strings and returns a value that represents therepresents the result of the comparison

result of the comparison String

String Returns a string that contains a repeating chReturns a string that contains a repeating character of aaracter of a specified length

specified length StrReverse

StrReverse Reverses a stringReverses a string UCase

UCase Converts a specified string to uppercaseConverts a specified string to uppercase

9. Other Functions

9. Other Functions TTopop

F

Fuunnccttiioonn DDeessccrriippttiioonn CreateObject

CreateObject Creates an object of a specified typeCreates an object of a specified type E

Evvaall EEvvaalluuaattees s aan n eexxpprreessssiioon n aannd d rreettuurrnns s tthhe e rreessuulltt GetLocale

GetLocale Returns the current locale IDReturns the current locale ID GetObject

GetObject Returns a reference to an automation object from a fileReturns a reference to an automation object from a file GetRef 

GetRef  Allows you to connect a VBScript procedure to Allows you to connect a VBScript procedure to a DHTMLa DHTML event on your pages

event on your pages InputBox

InputBox Displays a dialog box, where the user can write some inputDisplays a dialog box, where the user can write some input and/or click on a button, and returns the contents

and/or click on a button, and returns the contents IsEmpty

IsEmpty Returns a Boolean value that Returns a Boolean value that indicates whether a specifiedindicates whether a specified variable has been initialized or not

variable has been initialized or not IsNull

IsNull Returns a Boolean value that Returns a Boolean value that indicates whether a specifiedindicates whether a specified expression contains no valid data (Null)

expression contains no valid data (Null) IsNumeric

IsNumeric Returns a Boolean value that Returns a Boolean value that indicates whether a specifiedindicates whether a specified expression can be evaluated as a number 

expression can be evaluated as a number  IsObject

IsObject Returns a Boolean value that Returns a Boolean value that indicates whether the specifiedindicates whether the specified expression is an automation object

expression is an automation object LoadPicture

LoadPicture Returns a picture oReturns a picture object. Abject. Available only on vailable only on 32-bit platforms32-bit platforms MsgBox

MsgBox Displays a message box, waits for the user to cDisplays a message box, waits for the user to click a button,lick a button, and returns a value that indicates which button the user  and returns a value that indicates which button the user  clicked

clicked RGB

RGB Returns a number that represents an RGB cReturns a number that represents an RGB color valueolor value Round

Round Rounds a number Rounds a number 

ScriptEngine

ScriptEngine Returns the scripting language in useReturns the scripting language in use ScriptEngineBuildVersion

ScriptEngineBuildVersion Returns the build version number of the Returns the build version number of the scripting engine inscripting engine in use

use ScriptEngineMajorVersion

ScriptEngineMajorVersion Returns the major version number of the Returns the major version number of the scripting engine inscripting engine in use

use ScriptEngineMinorVersion

(8)

use use SetLocale

SetLocale Sets the locale ID and returns the previous locale IDSets the locale ID and returns the previous locale ID TypeName

TypeName Returns the subtype of a specified variableReturns the subtype of a specified variable VarType

VarType Returns a value that indicates the Returns a value that indicates the subtype of a specifiedsubtype of a specified variable

variable

10. Date / Time Functions Syntax with Example 10. Date / Time Functions Syntax with Example 10.1

10.1 Write textWrite text: : How to How to write text on write text on a pagea page <script type="text/vbscript">

<script type="text/vbscript">

document.write("Hello from VBScript!Written By k

document.write("Hello from VBScript!Written By kasi Visasi Viswaandham")waandham") </script>

</script> 10.2 CDATE 10.2 CDATE

The CDate function converts a

The CDate function converts a valid date and time expression to valid date and time expression to the variant of subtypethe variant of subtype Date, and returns the result.

Date, and returns the result. Tip:

Tip: Use the IsDate function to determine if date can be converted to a date or time.Use the IsDate function to determine if date can be converted to a date or time. Note:

Note: The IsDate function uses local setting to determine if The IsDate function uses local setting to determine if a string can be converted a string can be converted to ato a date ("January" is not a month

date ("January" is not a month in all languages.)in all languages.) CDate(date)

CDate(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y vvaalliid d ddaatte e eexxpprreessssiioon n ((lliikke e DDaattee(() ) oor r NNooww(()))) Example 1 Example 1 d="April 22, 2001" d="April 22, 2001" if IsDate(d) then if IsDate(d) then document.write(CDate(d)) document.write(CDate(d)) end if  end if  Output: Output: 2/22/01 2/22/01 Example 2 Example 2 d=#2/22/01# d=#2/22/01# if IsDate(d) then if IsDate(d) then document.write(CDate(d)) document.write(CDate(d)) end if  end if  Output: Output: 2/22/01 2/22/01 Example 3 Example 3 d="3:18:40 AM" d="3:18:40 AM" if IsDate(d) then if IsDate(d) then document.write(CDate(d)) document.write(CDate(d))

(9)

end if  end if  Output: Output: 3:18:40 AM 3:18:40 AM 10.3 Date 10.3 Date

The Date function returns the current

The Date function returns the current system datesystem date Syntax

Syntax

document.write("The current system date is: ") document.write("The current system date is: ") document.write(Date)

document.write(Date) Output:

Output:

The current system date is: 1/14/2002 The current system date is: 1/14/2002 10.4 DateAdd

10.4 DateAdd

The DateAdd function returns a date to which a specified time interval has been added. The DateAdd function returns a date to which a specified time interval has been added. Syntax

Syntax

DateAdd(interval,number,date) DateAdd(interval,number,date) P

Paarraammeetteerr DDeessccrriippttiioonn

iinntteerrvvaall RReeqquuiirreedd. . TThhe e iinntteerrvvaal l yyoou u wwaannt t tto o aadddd Can take the following values:

Can take the following values: •

• yyyy - yyyy - YYear ear  •

• q - Quarter q - Quarter  •

• m - Monthm - Month •

• y - Day of year y - Day of year  •

• d - Dayd - Day •

• w - Weekdayw - Weekday •

• ww - Week of year ww - Week of year  • • h - Hour h - Hour  • • n - Minuten - Minute • • s - Seconds - Second n

nuummbbeerr RReeqquuiirreedd. . TThhe ne nuummbbeer or of if inntteerrvvaal yl yoou wu waannt tt to ao adddd. C. Caan en eiitthheer br bee  positive, for dates in the future, or negative,

 positive, for dates in the future, or negative, for dates in the pastfor dates in the past d

daattee RReeqquuiirreedd. . VVaarriiaannt t oor r lliitteerraal l rreepprreesseennttiinng g tthhe e ddaatte e tto o wwhhiicch h iinntteerrvvaal l iiss added

added Example 1

Example 1

'Add one month to January 31, 2000 'Add one month to January 31, 2000

document.write(DateAdd("m",1,"31-Jan-00")) document.write(DateAdd("m",1,"31-Jan-00")) Output: Output: 2/29/2000 2/29/2000 Example 2 Example 2

'Add one month to January 31, 2001 'Add one month to January 31, 2001

document.write(DateAdd("m",1,"31-Jan-01")) document.write(DateAdd("m",1,"31-Jan-01"))

(10)

Output: Output: 2/28/2001 2/28/2001 10.5 DateDiff  10.5 DateDiff 

The DateDiff function returns the number of intervals between two

The DateDiff function returns the number of intervals between two dates.dates. Syntax

Syntax

DateDiff(interval,date1,date2[,firstdayofweek[,firstweekofyear]]) DateDiff(interval,date1,date2[,firstdayofweek[,firstweekofyear]]) P

Paarraammeetteerr DDeessccrriippttiioonn

iinntterervvalal RReeqquiuirreedd. . TThe he iinntteerrvaval yl yoou wu waannt tt to uo usse te to co calalccululaatte te thhe de diiffffeerreencnceess  between date1 and date2

 between date1 and date2

Can take the following values: Can take the following values:

• yyyy - yyyy - YYear ear  •

• q - Quarter q - Quarter  •

• m - Monthm - Month •

• y - Day of year y - Day of year  •

• d - Dayd - Day •

• w - Weekdayw - Weekday •

• ww - Week of year ww - Week of year  • • h - Hour h - Hour  • • n - Minuten - Minute • • s - Seconds - Second da

datete1,1,dadatete22 ReReququirireded. D. Datate exe exprpresessisionons. s. TTwo wo dadatetes ys you wou wanant tt to uo use se in in ththee calculation

calculation fir

firstdstdayayofwofweekeek OptOptionional. al. SpeSpecifcifies ies the the day day of of the the weeweek.k. Can take the following values:

Can take the following values: •

• 0 = vbUseS0 = vbUseSystemDayOfWystemDayOfWeek - Use eek - Use National Language SNational Language Supportupport (NLS) API setting

(NLS) API setting •

• 1 = vbSunday - Sunday (default)1 = vbSunday - Sunday (default) •

• 2 = vbMonday - Monday2 = vbMonday - Monday •

• 3 = vbTuesday - Tuesday3 = vbTuesday - Tuesday •

• 4 = vbWednesday - Wednesday4 = vbWednesday - Wednesday •

• 5 = vbThursday - Thursday5 = vbThursday - Thursday •

• 6 = vbFriday - Friday6 = vbFriday - Friday •

• 7 = vbSaturday - Saturday7 = vbSaturday - Saturday firs

firstweekotweekofyearfyear OptionOptional. Sal. Specifipecifies thes the fie first rst week oweek of thf the yee yearar.. Can take the following values:

(11)

• 0 = vbUseSystem - Use National Language 0 = vbUseSystem - Use National Language Support (NLS) APISupport (NLS) API setting

setting •

• 1 = vbFirstJan1 - Start with the week 1 = vbFirstJan1 - Start with the week in which January 1 occursin which January 1 occurs (default)

(default) •

• 2 = vbFirstFourDays - Start with the week that has at least four 2 = vbFirstFourDays - Start with the week that has at least four  days in the new year 

days in the new year  •

• 3 = vbFirstFullW3 = vbFirstFullWeek - Start with the first full week of the eek - Start with the first full week of the newnew year  year  Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(DateDiff("m",Date,"12/31/2002") & "<br />") document.write(DateDiff("m",Date,"12/31/2002") & "<br />") document.write(DateDiff("d",Date,"12/31/2002") & "<br />") document.write(DateDiff("d",Date,"12/31/2002") & "<br />") document.write(DateDiff("n",Date,"12/31/2002")) document.write(DateDiff("n",Date,"12/31/2002")) Output: Output: 1/14/2002 1/14/2002 11 11 351 351 505440 505440 10.6 DatePart 10.6 DatePart

The DatePart function returns the specified part o

The DatePart function returns the specified part of a given date.f a given date. Syntax

Syntax

DatePart(interval,

DatePart(interval, date[,firstdayofweek[,firsdate[,firstdayofweek[,firstweekofyear]])tweekofyear]]) P

Paarraammeetteerr DDeessccrriippttiioonn

iinntteerrvvaall RReeqquuiirreedd. . TThhe e iinntteerrvvaal l oof f ttiimme te to ro reettuurrnn.. Can take the following values:

Can take the following values: •

• yyyy - yyyy - YYear ear  •

• q - Quarter q - Quarter  •

• m - Monthm - Month •

• y - Day of year y - Day of year  •

• d - Dayd - Day •

• w - Weekdayw - Weekday •

• ww - Week of year ww - Week of year  • • h - Hour h - Hour  • • n - Minuten - Minute • • s - Seconds - Second d

daattee RReeqquuiirreedd. . DDaatte e eexxpprreessssiioon n tto o eevvaalluuaattee fir

(12)

Can take the following values: Can take the following values:

• 0 = vbUseS0 = vbUseSystemDayOfWystemDayOfWeek - Use eek - Use National Language SNational Language Supportupport (NLS) API setting

(NLS) API setting •

• 1 = vbSunday - Sunday (default)1 = vbSunday - Sunday (default) •

• 2 = vbMonday - Monday2 = vbMonday - Monday •

• 3 = vbTuesday - Tuesday3 = vbTuesday - Tuesday •

• 4 = vbWednesday - Wednesday4 = vbWednesday - Wednesday •

• 5 = vbThursday - Thursday5 = vbThursday - Thursday •

• 6 = vbFriday - Friday6 = vbFriday - Friday •

• 7 = vbSaturday - Saturday7 = vbSaturday - Saturday firs

firstweekotweekofyearfyear OptionOptional. Sal. Specifipecifies thes the fie first rst week oweek of thf the yee yearar.. Can take the following values:

Can take the following values: •

• 0 = vbUseSystem - Use National Language 0 = vbUseSystem - Use National Language Support (NLS) APISupport (NLS) API setting

setting •

• 1 = vbFirstJan1 - Start with the week 1 = vbFirstJan1 - Start with the week in which January 1 occursin which January 1 occurs (default)

(default) •

• 2 = vbFirstFourDays - Start with the week that has at least four 2 = vbFirstFourDays - Start with the week that has at least four  days in the new year 

days in the new year  •

• 3 = vbFirstFullW3 = vbFirstFullWeek - Start with the first full week of the eek - Start with the first full week of the newnew year  year  Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(DatePart("d",Date)) document.write(DatePart("d",Date)) Output: Output: 1/14/2002 1/14/2002 14 14 10.7 DateSerial 10.7 DateSerial

The DateSerial function

The DateSerial function returns a Vreturns a Variant of subtype Date ariant of subtype Date for a specified year, month, andfor a specified year, month, and day. day. Syntax Syntax DateSerial(year,month,day) DateSerial(year,month,day) P

Paarraammeetteerr DDeessccrriippttiioonn y

yeeaarr RReeqquuiirreedd. . A A nnuummbbeer r bbeettwweeeen n 11000 0 aannd d 99999999, , oor r a a nnuummeerriic c eexxpprreessssiioonn.. V

Values between 0 and alues between 0 and 99 are interpreted as the years 1900–199 are interpreted as the years 1900–1999. For all999. For all other year arguments, use a complete four-digit year 

other year arguments, use a complete four-digit year  m

(13)

d

daayy RReeqquuiirreedd. . AAnny y nnuummeerriic c eexxpprreessssiioonn Example 1 Example 1 document.write(DateSerial(1996,2,3) & "<br />") document.write(DateSerial(1996,2,3) & "<br />") document.write(DateSerial(1990-20,9-2,1-1)) document.write(DateSerial(1990-20,9-2,1-1)) Output: Output: 2/3/1996 2/3/1996 6/30/1970 6/30/1970 10.8

10.8 DateVDateValuealue The DateV

The DateValue function alue function returns a Vreturns a Variant of subtype ariant of subtype Date.Date. Note:

Note: If the year part of date is omitted this function If the year part of date is omitted this function will use the current year from thewill use the current year from the computer's system date.

computer's system date. Note:

Note: If the date parameter includes time information it will not be If the date parameter includes time information it will not be returned. However, if returned. However, if  date includes invalid

date includes invalid time information, a run-time error time information, a run-time error will occur.will occur. Syntax

Syntax

DateValue(date) DateValue(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . A A ddaatte fe frroom m JJaannuuaarry y 11, , 11000 0 tthhrroouuggh Dh Deecceemmbbeer r 3311, , 9999999 o9 or  r   any expression that can represent a date, a time, or both a date and time any expression that can represent a date, a time, or both a date and time Example 1

Example 1

document.write(DateV

document.write(DateValue("31-Jan-02") & alue("31-Jan-02") & "<br />")"<br />") document.write(DateV

document.write(DateValue("31-Jan") & alue("31-Jan") & "<br />")"<br />") document.write(DateV

document.write(DateValue("31-Jan-02 alue("31-Jan-02 2:39:49 AM"))2:39:49 AM")) Output: Output: 1/31/2002 1/31/2002 1/31/2002 1/31/2002 1/31/2002 1/31/2002 10.9 Day 10.9 Day

The Day function returns a number between 1 and 31 that represents the day of the The Day function returns a number between 1 and 31 that represents the day of the month. month. Syntax Syntax Day(date) Day(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y eexxpprreessssiioon n tthhaat t ccaan n rreepprreesseennt t a a ddaattee Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(Day(Date)) document.write(Day(Date))

(14)

Output: Output: 1/14/2002 1/14/2002 14 14 10.10 FormatDateTime 10.10 FormatDateTime

The FormatDateTime function formats and returns a valid date or time expression. The FormatDateTime function formats and returns a valid date or time expression. Syntax

Syntax

FormatDateTime(date,format) FormatDateTime(date,format) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y vvaalliid d ddaatte e eexxpprreessssiioon n ((lliikke e DDaattee(() ) oor r NNooww(())))

ffoorrmmaatt OOppttiioonnaall. . AA FormatFormatvalue that specifies the date/time format to usevalue that specifies the date/time format to use Example 1

Example 1

document.write("The current date is: ") document.write("The current date is: ") document.write(FormatDateTime(Date())) document.write(FormatDateTime(Date())) Output:

Output:

The current date is: 2/22/2001 The current date is: 2/22/2001

10.11 Hour 10.11 Hour

The Hour function returns a number between 0 and 23 that represents the hour of the day. The Hour function returns a number between 0 and 23 that represents the hour of the day. Syntax

Syntax Hour(time) Hour(time) P

Paarraammeetteerr DDeessccrriippttiioonn

ttiimmee RReeqquuiirreedd. . AAnny y eexxpprreessssiioon n tthhaat t ccaan n rreepprreesseennt t a a ttiimmee Example 1 Example 1 document.write(Now & "<br />") document.write(Now & "<br />") document.write(Hour(Now)) document.write(Hour(Now)) Output: Output: 1/15/2002 10:07:47 AM 1/15/2002 10:07:47 AM 10 10 10.12 IsDate 10.12 IsDate

The IsDate function returns a Boolean

The IsDate function returns a Boolean value that indicates if the evaluated value that indicates if the evaluated expression canexpression can  be converted to a

 be converted to a date. It returns True if the expression is a date or can be date. It returns True if the expression is a date or can be converted to aconverted to a date; otherwise, it returns False.

date; otherwise, it returns False. Note:

Note: The IsDate function uses local setting to determine if The IsDate function uses local setting to determine if a string can be converted a string can be converted to ato a date ("January" is not a month

date ("January" is not a month in all languages.)in all languages.) Syntax

(15)

IsDate(expression) IsDate(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexpxprreessssiioonn RReeqquiuirreedd. . TThe he exexpprresesssiioon tn to bo be ee evavalluauatteded Example 1

Example 1

document.write(IsDate("April 22, 1947") & "<br />") document.write(IsDate("April 22, 1947") & "<br />") document.write(IsDate(#1

document.write(IsDate(#11/11/01#) & "1/11/01#) & "<br />")<br />") document.write(IsDate("#1

document.write(IsDate("#11/11/01#") & "<br 1/11/01#") & "<br />")/>") document.write(IsDate("Hello

document.write(IsDate("Hello WWorld!"))orld!")) Output: Output: True True True True False False False False 10.13 Minute 10.13 Minute

The Minute function returns a number between 0 and 59 that represents the minute of the The Minute function returns a number between 0 and 59 that represents the minute of the hour. hour. Syntax Syntax Minute(time) Minute(time) P

Paarraammeetteerr DDeessccrriippttiioonn

ttiimmee RReeqquuiirreedd. . AAnny y eexxpprreessssiioon n tthhaat t ccaan n rreepprreesseennt t a a ttiimmee Example 1 Example 1 document.write(Now & "<br />") document.write(Now & "<br />") document.write(Minute(Now)) document.write(Minute(Now)) Output: Output: 1/15/2002 10:34:39 AM 1/15/2002 10:34:39 AM 34 34 10.14 Month 10.14 Month

The Month function returns a number between 1 and 12 that represents the month of the The Month function returns a number between 1 and 12 that represents the month of the year. year. Syntax Syntax Month(date) Month(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y eexxpprreessssiioon n tthhaat t ccaan n rreepprreesseennt t a a ddaattee Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(Month(Date)) document.write(Month(Date)) Output: Output:

(16)

1/15/2002 1/15/2002 1 1 10.15 MonthName 10.15 MonthName

The MonthName function returns the name of the specified month. The MonthName function returns the name of the specified month. Syntax

Syntax

MonthName(month[,abbreviate]) MonthName(month[,abbreviate]) P

Paarraammeetteerr DDeessccrriippttiioonn m

moonntthh RReeqquiuirreedd. . SSppececiiffiiees s tthe he nnumumbbeer r oof f tthhe e mmonontth h ((JJaannuauarry y iis s 11, , FFeebrbruuaary ry iiss 2, etc.)

2, etc.) ab

abbrbreveviaiatete OpOptitiononalal. . A A BoBoololeaean vn valalue ue ththat at inindidicacatetes is if tf the he momontnth nh namame ie is ts to bo bee abbreviated. Default is False

abbreviated. Default is False Example 1 Example 1 document.write(MonthName(8)) document.write(MonthName(8)) Output: Output: August August 10.16 Now 10.16 Now

The Now function returns the current

The Now function returns the current date and time according to date and time according to the setting of your the setting of your  computer's system date and time.

computer's system date and time.  Now  Now Example 1 Example 1 document.write(Now) document.write(Now) Output: Output: 1/15/2002 10:52:15 AM 1/15/2002 10:52:15 AM 10.17 Second 10.17 Second

The Second function returns a number between 0 and 59 that represents the second of the The Second function returns a number between 0 and 59 that represents the second of the minute.

minute. Second(time) Second(time) P

Paarraammeetteerr DDeessccrriippttiioonn

ttiimmee RReeqquuiirreedd. . AAnny y eexxpprreessssiioon n tthhaat t ccaan n rreepprreesseennt t a a ttiimmee Example 1 Example 1 document.write(Now & "<br />") document.write(Now & "<br />") document.write(Second(Now)) document.write(Second(Now)) Output: Output: 1/15/2002 10:55:51 AM 1/15/2002 10:55:51 AM 51 51

(17)

Example 2 Example 2 document.write(Second(Time)) document.write(Second(Time)) Output: Output: 51 51 10.18 Time 10.18 Time

The Time function returns the current

The Time function returns the current system time.system time. Syntax Syntax Time Time Example 1 Example 1 document.write(Time) document.write(Time) Output: Output: 11:07:27 AM 11:07:27 AM 10.19 Timer 10.19 Timer

The Timer function returns the number

The Timer function returns the number of seconds since 12:00 AM.of seconds since 12:00 AM. Syntax Syntax Timer  Timer  Example 1 Example 1 document.write(Time & "<br />") document.write(Time & "<br />") document.write(Timer) document.write(Timer) Output: Output: 11:11:13 AM 11:11:13 AM 40273.2 40273.2 10.20 TimeSerial 10.20 TimeSerial

The TimeSerial function returns the time for a specific hour, minute, and second. The TimeSerial function returns the time for a specific hour, minute, and second. Syntax

Syntax

TimeSerial(hour,minute,second) TimeSerial(hour,minute,second) P

Paarraammeetteerr DDeessccrriippttiioonn h

hoouurr RReeqquuiirreedd. . A A nnuummbbeer r bbeettwweeeen n 0 0 aannd d 2233, , oor r a a nnuummeerriic c eexxpprreessssiioonn m

miinnuuttee RReeqquuiirreedd. . AAnny y nnuummeerriic ec exxpprreessssiioonn sseeccoonndd RReeqquuiirreedd. . AAnny y nnuummeerriic ec exxpprreessssiioonn

Example 1 Example 1

document.write(TimeSerial(

document.write(TimeSerial(23,2,3) & 23,2,3) & "<br />")"<br />") document.write(TimeSerial(

document.write(TimeSerial(0,9,11) & "<br 0,9,11) & "<br />")/>") document.write(TimeSerial(14+2,9-2,1-1)) document.write(TimeSerial(14+2,9-2,1-1)) Output: Output: 11:02:03 PM 11:02:03 PM

(18)

12:09:11 AM 12:09:11 AM 4:07:00 PM 4:07:00 PM

10.21

10.21 TimeVTimeValuealue The TimeV

The TimeValue function alue function returns a Vreturns a Variant of subtariant of subtype Date that ype Date that contains the contains the time.time. Syntax

Syntax

TimeValue(time) TimeValue(time) P

Paarraammeetteerr DDeessccrriippttiioonn

ttiimmee RReeqquuiirreedd. . A A ttiimme fe frroom m 00::0000::000 (0 (1122::0000::000 0 AA..MM..) ) tto 2o 233::5599::559 (9 (1111::5599::5599 P

P.M.) or any ex.M.) or any expression that represents a time pression that represents a time in that rangein that range Example 1

Example 1

document.write(TimeV

document.write(TimeValue("5:55:59 PM") alue("5:55:59 PM") & "<br & "<br />")/>") document.write(TimeV

document.write(TimeValue(#5:55:59 PM#) alue(#5:55:59 PM#) & "<br & "<br />")/>") document.write(TimeValue("15:34")) document.write(TimeValue("15:34")) Output: Output: 5:55:59 PM 5:55:59 PM 5:55:59 PM 5:55:59 PM 3:34:00 PM 3:34:00 PM 10.22 Weekday 10.22 Weekday The W

The Weekday function returns a number between eekday function returns a number between 1 and 7, inclusive, that 1 and 7, inclusive, that represents therepresents the day of the week.

day of the week. Syntax

Syntax

Weekday(date[,firstdayofweek]) Weekday(date[,firstdayofweek]) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . TThhe e ddaatte e eexxpprreessssiioon n tto o eevvaalluuaattee fir

firstdstdayayofwofweekeek OptOptionional. Sal. Specipecifiefies the s the firfirst dst day of ay of the wthe week.eek. Can take the following values:

Can take the following values: •

• 0 = vbUseS0 = vbUseSystemDayOfWystemDayOfWeek - Use eek - Use National Language SNational Language Supportupport (NLS) API setting

(NLS) API setting •

• 1 = vbSunday - Sunday (default)1 = vbSunday - Sunday (default) •

• 2 = vbMonday - Monday2 = vbMonday - Monday •

• 3 = vbTuesday - Tuesday3 = vbTuesday - Tuesday •

• 4 = vbWednesday - Wednesday4 = vbWednesday - Wednesday •

• 5 = vbThursday - Thursday5 = vbThursday - Thursday •

• 6 = vbFriday - Friday6 = vbFriday - Friday •

(19)

Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(Weekday(Date)) document.write(Weekday(Date)) Output: Output: 1/15/2002 1/15/2002 3 3 10.23 WeekdayName 10.23 WeekdayName The W

The WeekdayName function returns the weekday name eekdayName function returns the weekday name of a specified day of the of a specified day of the week.week. Syntax

Syntax

WeekdayName(weekday[,abbreviate[,firstdayofweek]]) WeekdayName(weekday[,abbreviate[,firstdayofweek]]) P

Paarraammeetteerr DDeessccrriippttiioonn w

weeeekkddaayy RReeqquuiirreedd. . TThhe e nnuummbbeer r oof f tthhe e wweeeekkddaayy ab

abbrbreveviaiatete OpOptitiononalal. . A A BoBoololeaean vn valalue ue ththat at inindidicacatetes is if tf the he weweekekdaday ny namame ie is ts to bo bee abbreviated

abbreviated fir

firstdstdayayofwofweekeek OptOptionional. Sal. Specipecifiefies the s the firfirst dst day of ay of the wthe week.eek. Can take the following values:

Can take the following values: •

• 0 = vbUseS0 = vbUseSystemDayOfWystemDayOfWeek - Use eek - Use National Language SNational Language Supportupport (NLS) API setting

(NLS) API setting •

• 1 = vbSunday - Sunday (default)1 = vbSunday - Sunday (default) •

• 2 = vbMonday - Monday2 = vbMonday - Monday •

• 3 = vbTuesday - Tuesday3 = vbTuesday - Tuesday •

• 4 = vbWednesday - Wednesday4 = vbWednesday - Wednesday •

• 5 = vbThursday - Thursday5 = vbThursday - Thursday •

• 6 = vbFriday - Friday6 = vbFriday - Friday •

• 7 = vbSaturday - Saturday7 = vbSaturday - Saturday Example 1 Example 1 document.write(WeekdayName(3)) document.write(WeekdayName(3)) Output: Output: Tuesday Tuesday 10.24 Year 10.24 Year The Y

The Year function ear function returns a number returns a number that represents the that represents the year.year. Syntax

Syntax Year(date) Year(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

(20)

Example 1 Example 1 document.write(Date & "<br />") document.write(Date & "<br />") document.write(Year(Date)) document.write(Year(Date)) Output: Output: 1/15/2002 1/15/2002 2002 2002

11. Conversion Functions Syntax with Example 11. Conversion Functions Syntax with Example 11.1 Asc

11.1 Asc

The Asc function converts the first letter in a string to ANSI code, and returns the result. The Asc function converts the first letter in a string to ANSI code, and returns the result. Syntax

Syntax Asc(string) Asc(string) P

Paarraammeetteerr DDeessccrriippttiioonn

ssttrriinngg RReeqquuiirreedd. . A A ssttrriinng g eexxpprreessssiioonn. . CCaannnnoot t bbe e aan n eemmpptty y ssttrriinngg!! Example 1 Example 1 document.write(Asc("A") & "<br />") document.write(Asc("A") & "<br />") document.write(Asc("F")) document.write(Asc("F")) Output: Output: 65 65 70 70 11.2 CBool 11.2 CBool

The CBool function converts an expression to a variant of subtype Boolean. The CBool function converts an expression to a variant of subtype Boolean. Syntax

Syntax

CBool(expression) CBool(expression) P

Paarraammeetteerr DDeessccrriippttiioonn ex

exprpresessisionon ReReququirireded. . AnAny vy valalid eid expxpreressssioion. n. A A nononznzerero vao valulue ree retuturnrns Ts Trurue, ze, zereroo returns False. A r

returns False. A run-time error occurs if un-time error occurs if the expression can the expression can not benot be interpreted as a numeric value

interpreted as a numeric value Example 1 Example 1 dim a,b dim a,b a=5 a=5  b=10  b=10 document.write(CBool(a) & "<br />") document.write(CBool(a) & "<br />") document.write(CBool(b)) document.write(CBool(b)) Output: Output: True True True True 11.3 CByte 11.3 CByte

(21)

The CByte function converts an expression to a variant of subtype Byte. The CByte function converts an expression to a variant of subtype Byte. Syntax

Syntax

CByte(expression) CByte(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a dim a a=134.345 a=134.345 document.write(CByte(a)) document.write(CByte(a)) Output: Output: 134 134 11.4 CCur 11.4 CCur

The CCur function converts an

The CCur function converts an expression to a variant of subtype Currency.expression to a variant of subtype Currency. Syntax

Syntax

CCur(expression) CCur(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a dim a a=134.345 a=134.345 document.write(CCur(a)) document.write(CCur(a)) Output: Output: 134.345 134.345 11.5 CDate 11.5 CDate

The CDate function converts a

The CDate function converts a valid date and time expression to valid date and time expression to the variant of subtypethe variant of subtype Date, and returns the result.

Date, and returns the result. Tip:

Tip: Use the IsDate function to determine if date can be converted to a date or time.Use the IsDate function to determine if date can be converted to a date or time. Note:

Note: The IsDate function uses local setting to determine if The IsDate function uses local setting to determine if a string can be converted a string can be converted to ato a date ("January" is not a month

date ("January" is not a month in all languages.)in all languages.) Syntax

Syntax CDate(date) CDate(date) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y vvaalliid d ddaatte e eexxpprreessssiioon n ((lliikke e DDaattee(() ) oor r NNooww(()))) Example 1

(22)

d="April 22, 2001" d="April 22, 2001" if IsDate(d) then if IsDate(d) then document.write(CDate(d)) document.write(CDate(d)) end if  end if  Output: Output: 2/22/01 2/22/01 Example 2 Example 2 d=#2/22/01# d=#2/22/01# if IsDate(d) then if IsDate(d) then document.write(CDate(d)) document.write(CDate(d)) end if  end if  Output: Output: 2/22/01 2/22/01 11.6 CDbl 11.6 CDbl

The CDbl function converts an

The CDbl function converts an expression to a variant of subtype Double.expression to a variant of subtype Double. Syntax

Syntax

CDbl(expression) CDbl(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a dim a a=134.345 a=134.345 document.write(CDbl(a)) document.write(CDbl(a)) Output: Output: 134.345 134.345 11.7 Chr 11.7 Chr

The Chr function converts the

The Chr function converts the specified ANspecified ANSI character code to SI character code to a character.a character. Note:

Note: The numbers from 0 to 31 represents nonprintable ASCII codes, i.e. Chr(10) willThe numbers from 0 to 31 represents nonprintable ASCII codes, i.e. Chr(10) will return a linefeed

return a linefeed charactercharacter.. Syntax

Syntax

Chr(charcode) Chr(charcode) P

Paarraammeetteerr DDeessccrriippttiioonn

cchhaarrccooddee RReeqquuiirreedd. . A A nnuummbbeer tr thhaat it iddeennttiiffiiees a s a cchhaarraacctteer r  Example 1 Example 1 document.write(Chr(65) & "<br />") document.write(Chr(65) & "<br />") document.write(Chr(97)) document.write(Chr(97)) Output: Output:

(23)

A A aa

11.8 CInt 11.8 CInt

The CInt function converts an

The CInt function converts an expression to a variant of subtype Integer.expression to a variant of subtype Integer. Note:

Note: The value must be a number between -32768 and 32767.The value must be a number between -32768 and 32767. Syntax

Syntax

CInt(expression) CInt(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a dim a a=134.345 a=134.345 document.write(CInt(a)) document.write(CInt(a)) Output: Output: 134 134 11.9 CLng 11.9 CLng

The CLng function converts an expression to a variant of subtype Long. The CLng function converts an expression to a variant of subtype Long. Note:

Note: The value must be a number between -2147483648 and 2147483647.The value must be a number between -2147483648 and 2147483647. Syntax

Syntax

CLng(expression) CLng(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a,b dim a,b a=23524.45 a=23524.45  b=23525.55  b=23525.55 document.write(CLng(a) & "<br />") document.write(CLng(a) & "<br />") document.write(CLng(b)) document.write(CLng(b)) Output: Output: 23524 23524 23526 23526 11.10 CSng 11.10 CSng

The CSng function converts an expression to a variant of subtype Single. The CSng function converts an expression to a variant of subtype Single. Syntax

(24)

CSng(expression) CSng(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn Example 1 Example 1 dim a,b dim a,b a=23524.4522 a=23524.4522  b=23525.5533  b=23525.5533 document.write(CSng(a) & "<br />") document.write(CSng(a) & "<br />") document.write(CSng(b)) document.write(CSng(b)) Output: Output: 23524.45 23524.45 23525.55 23525.55 11.11 CStr 11.11 CStr

The CStr function converts an expression to a variant of subtype String. The CStr function converts an expression to a variant of subtype String. Syntax

Syntax

CStr(expression) CStr(expression) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. . AAny ny vvaalliid d eexxpprreessssiioonn If expression is:

If expression is: •

• Boolean - then the CStr function will return a string containingBoolean - then the CStr function will return a string containing true or false.

true or false. •

• Date - then the CStr function will return a string that contains aDate - then the CStr function will return a string that contains a date in the short-date format.

date in the short-date format. •

•  Null - then  Null - then a run-time error will occur.a run-time error will occur. •

• Empty - then the CStr function will return an empty string ("").Empty - then the CStr function will return an empty string (""). •

• Error - then the CStr function will return a Error - then the CStr function will return a string that containsstring that contains the word "Error" followed by an error number.

the word "Error" followed by an error number. •

• Other numeric - then the CStr function Other numeric - then the CStr function will return a string thatwill return a string that contains the

contains the number.number. Example 1 Example 1 dim a dim a ox ox 11.12 Hex 11.12 Hex

The Hex function returns a

The Hex function returns a string that represents the hexadecimal value of a string that represents the hexadecimal value of a specifiedspecified number.

(25)

Note:

Note: If number is not already a whole If number is not already a whole number, it is rounded to the nearest whole number number, it is rounded to the nearest whole number   before being evaluated.

 before being evaluated. Syntax

Syntax Hex(number) Hex(number) P

Paarraammeetteerr DDeessccrriippttiioonn n

nuummbbeerr RReeqquuiirreedd. . AAnny y vvaalliid ed exxpprreessssiioonn If number is:

If number is: •

•  Null - then the Hex function  Null - then the Hex function returns Null.returns Null. •

• Empty - then the Hex function returns zero (0).Empty - then the Hex function returns zero (0). •

• Any other number - then the Hex function returns up to eightAny other number - then the Hex function returns up to eight hexadecimal characters. hexadecimal characters. Example 1 Example 1 document.write(Hex(3) & "<br />") document.write(Hex(3) & "<br />") document.write(Hex(5) & "<br />") document.write(Hex(5) & "<br />") document.write(Hex(9) & "<br />") document.write(Hex(9) & "<br />") document.write(Hex(10) & "<br />") document.write(Hex(10) & "<br />") document.write(Hex(11) & "<br />") document.write(Hex(11) & "<br />") document.write(Hex(12) & "<br />") document.write(Hex(12) & "<br />") document.write(Hex(400) & "<br />") document.write(Hex(400) & "<br />") document.write(Hex(459) & "<br />") document.write(Hex(459) & "<br />") document.write(Hex(460)) document.write(Hex(460)) Output: Output: 3 3 5 5 9 9 A A B B C C 190 190 1CB 1CB 1CC 1CC 11.13 Oct 11.13 Oct

The Oct function returns a string that represents the

The Oct function returns a string that represents the octal value of a specified nuoctal value of a specified numbermber.. Note:

Note: If number is not already a whole If number is not already a whole number, it is rounded to the nearest whole number number, it is rounded to the nearest whole number   before being evaluated.

 before being evaluated. Syntax Syntax Oct(number) Oct(number) Page 25 of 69 Page 25 of 69

(26)

P

Paarraammeetteerr DDeessccrriippttiioonn n

nuummbbeerr RReeqquuiirreedd. . AAnny y vvaalliid ed exxpprreessssiioonn If number is:

If number is: •

•  Null - then the Oct function returns Null. Null - then the Oct function returns Null. •

• Empty - then the Oct function returns zero (0).Empty - then the Oct function returns zero (0). •

• Any other number - then the Any other number - then the Oct function returns up to 11 octalOct function returns up to 11 octal characters. characters. Example 1 Example 1 document.write(Oct(3) & "<br />") document.write(Oct(3) & "<br />") document.write(Oct(5) & "<br />") document.write(Oct(5) & "<br />") document.write(Oct(9) & "<br />") document.write(Oct(9) & "<br />") document.write(Oct(10) & "<br />") document.write(Oct(10) & "<br />") document.write(Oct(11) & "<br />") document.write(Oct(11) & "<br />") document.write(Oct(12) & "<br />") document.write(Oct(12) & "<br />") document.write(Oct(400) & "<br />") document.write(Oct(400) & "<br />") document.write(Oct(459) & "<br />") document.write(Oct(459) & "<br />") document.write(Oct(460)) document.write(Oct(460)) Output: Output: 3 3 5 5 11 11 12 12 13 13 14 14 620 620 713 713 714 714

12. Format Functions Syntax with Example 12. Format Functions Syntax with Example 12.1 FormatCurrency

12.1 FormatCurrency

The FormatCurrency function returns an expression formatted as a

The FormatCurrency function returns an expression formatted as a currency value usingcurrency value using the currency symbol defined in the co

the currency symbol defined in the computer's control panel.mputer's control panel. Syntax Syntax FormatCurrency(Expression[,NumDigAfterDec[, FormatCurrency(Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. T. Thhe ee exxpprreessssiioon tn to bo be fe foorrmmaatttteedd  NumDi

 NumDigAftegAfterDecrDec OptioOptional. Innal. Indicatedicates how mas how many placny places to tes to the righhe right of tht of the decimae decimal arel are displayed. Default is -1 (the computer's regional settings are used) displayed. Default is -1 (the computer's regional settings are used) In

(27)

fractional values: fractional values:

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False UseParForNegNum

UseParForNegNum Optional. Indicates whether or not Optional. Indicates whether or not to place negative values withinto place negative values within  parentheses:

 parentheses: •

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False G

GrrooupupDDiigg OOptptiioonnalal. I. Innddiiccatatees ws whheettheher or or nr noot nt numumbeberrs as arre ge grroouupeped ud ussiing ng tthehe group delimiter specified in the computer's regional settings: group delimiter specified in the computer's regional settings:

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False Example 1 Example 1 document.write(FormatCurrency(20000)) document.write(FormatCurrency(20000)) Output: Output: $20,000.00 $20,000.00 Example 2 Example 2 document.write(FormatCurrency(20000.578,2)) document.write(FormatCurrency(20000.578,2)) Output: Output: $20,000.58 $20,000.58 12.2 FormatDateTime 12.2 FormatDateTime

The FormatDateTime function formats and returns a valid date or time expression. The FormatDateTime function formats and returns a valid date or time expression. Syntax

Syntax

FormatDateTime(date,format) FormatDateTime(date,format) P

Paarraammeetteerr DDeessccrriippttiioonn d

daattee RReeqquuiirreedd. . AAnny y vvaalliid d ddaatte e eexxpprreessssiioon n ((lliikke e DDaattee(() ) oor r NNooww(())))

ffoorrmmaatt OOppttiioonnaall. . AA FormatFormatvalue that specifies the date/time format to usevalue that specifies the date/time format to use Example 1

Example 1

document.write("The current date is: ") document.write("The current date is: ") document.write(FormatDateTime(Date())) document.write(FormatDateTime(Date())) Output:

Output:

The current date is: 2/22/2001 The current date is: 2/22/2001

Example 2 Example 2

(28)

document.write("The current date is: ") document.write("The current date is: ") document.write(FormatDateTime(Date(),1)) document.write(FormatDateTime(Date(),1)) Output:

Output:

The current date

The current date is: Thursdayis: Thursday, February 22, , February 22, 20012001 12.3 FormatNumber

12.3 FormatNumber

The FormatNumber function returns an expression formatted as a number. The FormatNumber function returns an expression formatted as a number. Syntax Syntax FormatNumber(Expression[,NumDigAfterDec[, FormatNumber(Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. T. Thhe ee exxpprreessssiioon tn to bo be fe foorrmmaatttteedd  NumDi

 NumDigAftegAfterDecrDec OptioOptional. Innal. Indicatedicates how mas how many placny places to tes to the righhe right of tht of the decimae decimal arel are displayed. Default is -1 (the computer's regional settings are used) displayed. Default is -1 (the computer's regional settings are used) In

IncLcLeaeadidingDngDigig OpOptitiononalal. In. Indidicatcates wes whehethther oer or nor not a let a leadadining zerg zero is do is disisplplayayed fed for or  fractional values:

fractional values: •

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False UseParForNegNum

UseParForNegNum Optional. Indicates whether or not Optional. Indicates whether or not to place negative values withinto place negative values within  parentheses:

 parentheses: •

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False G

GrrooupupDDiigg OOptptiioonnalal. I. Innddiiccatatees ws whheettheher or or nr noot nt numumbeberrs as arre ge grroouupeped ud ussiing ng tthehe group delimiter specified in the computer's regional settings: group delimiter specified in the computer's regional settings:

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False Example 1 Example 1 document.write(FormatNumber(20000)) document.write(FormatNumber(20000)) Output: Output: 20,000.00 20,000.00 Example 2 Example 2 document.write(FormatNumber(20000.578,2)) document.write(FormatNumber(20000.578,2)) Output: Output: 20,000.58 20,000.58

(29)

12.4 FormatPercent 12.4 FormatPercent

The FormatPercent function returns an expression formatted as a percentage (multiplied The FormatPercent function returns an expression formatted as a percentage (multiplied  by 100) with

 by 100) with a trailing % character.a trailing % character. Syntax Syntax FormatPercent(Expression[,NumDigAfterDec[, FormatPercent(Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) P

Paarraammeetteerr DDeessccrriippttiioonn

eexxpprreessssiioonn RReeqquuiirreedd. T. Thhe ee exxpprreessssiioon tn to bo be fe foorrmmaatttteedd  NumDi

 NumDigAftegAfterDecrDec OptioOptional. Innal. Indicatedicates how mas how many placny places to tes to the righhe right of tht of the decimae decimal arel are displayed. Default is -1 (the computer's regional settings are used) displayed. Default is -1 (the computer's regional settings are used) In

IncLcLeaeadidingDngDigig OpOptitiononalal. In. Indidicatcates wes whehethther oer or nor not a let a leadadining zerg zero is do is disisplplayayed fed for or  fractional values:

fractional values: •

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False UseParForNegNum

UseParForNegNum Optional. Indicates whether or not Optional. Indicates whether or not to place negative values withinto place negative values within  parentheses:

 parentheses: •

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False G

GrrooupupDDiigg OOptptiioonnalal. I. Innddiiccatatees ws whheettheher or or nr noot nt numumbeberrs as arre ge grroouupeped ud ussiing ng tthehe group delimiter specified in the computer's regional settings: group delimiter specified in the computer's regional settings:

• -2 = TristateUseDefault - Use the computer's regional -2 = TristateUseDefault - Use the computer's regional settingssettings •

• -1 = TristateTrue - True-1 = TristateTrue - True •

• 0 = TristateFalse - False0 = TristateFalse - False Example 1

Example 1

'How many percent is 6 of 345? 'How many percent is 6 of 345?

document.write(FormatPercent(6/345)) document.write(FormatPercent(6/345)) Output: Output: 1.74% 1.74% Example 2 Example 2

'How many percent is 6 of 345? 'How many percent is 6 of 345?

document.write(FormatPercent(6/345,1)) document.write(FormatPercent(6/345,1)) Output: Output: 1.7% 1.7% Page 29 of 69 Page 29 of 69

(30)

13. Math Functions Syntax with Example 13. Math Functions Syntax with Example 13.1 Abs

13.1 Abs

The Abs function returns the absolute

The Abs function returns the absolute value of a value of a specified number.specified number. Note:

Note: If the number parameter contains Null, Null will be returnedIf the number parameter contains Null, Null will be returned Note:

Note: If the number parameter is an uninitialized variable, If the number parameter is an uninitialized variable, zero will be returned.zero will be returned. Syntax

Syntax

Abs(number) Abs(number) P

Paarraammeetteerr DDeessccrriippttiioonn n

nuummbbeerr RReeqquuiirreedd. . A A nnuummeerriic c eexxpprreessssiioonn Example 1 Example 1 document.write(Abs(1) & "<br />") document.write(Abs(1) & "<br />") document.write(Abs(-1)) document.write(Abs(-1)) Output: Output: 1 1 1 1 Example 2 Example 2 document.write(Abs(48.4) & "<br />") document.write(Abs(48.4) & "<br />") document.write(Abs(-48.4)) document.write(Abs(-48.4)) Output: Output: 48.4 48.4 48.4 48.4 13.2 Atn 13.2 Atn

The Atn function returns the arctangent

The Atn function returns the arctangent of a specified of a specified numbernumber.. Syntax

Syntax Atn(number) Atn(number) P

Paarraammeetteerr DDeessccrriippttiioonn n

nuummbbeerr RReeqquuiirreedd. . A A nnuummeerriic c eexxpprreessssiioonn Example 1 Example 1 document.write(Atn(89)) document.write(Atn(89)) Output: Output: 1.55956084453693 1.55956084453693 Example 2 Example 2 document.write(Atn(8.9)) document.write(Atn(8.9)) Output: Output: 1.45890606062322 1.45890606062322 13.3 Cos 13.3 Cos

(31)

The Cos function returns the cosine of a specified number (angle). The Cos function returns the cosine of a specified number (angle). Syntax

Syntax Cos(number) Cos(number) P

Paarraammeetteerr DDeessccrriippttiioonn n

numumbberer RReeqquiuirreedd. . A A nnumumereriic ec exxpprreessssiioon tn thahat t exexpprreesssses es aan an anngglle ie in rn raadidiaannss Example 1 Example 1 document.write(Cos(50.0)) document.write(Cos(50.0)) Output: Output: 0.964966028492113 0.964966028492113 Example 2 Example 2 document.write(Cos(-50.0)) document.write(Cos(-50.0)) Output: Output: 0.964966028492113 0.964966028492113 13.4. Exp 13.4. Exp

The Exp function returns

The Exp function returns ee raised to a raised to a powerpower.. Note:

Note: The value of number cannot exceed 709.782712893.The value of number cannot exceed 709.782712893. Tip:

Tip: Also look at the Log function.Also look at the Log function. Syntax

Syntax Exp(number) Exp(number) P

Paarraammeetteerr DDeessccrriippttiioonn n

nuummbbeerr RReeqquuiirreedd. . A A vvaalliid d nnuummeerriic c eexxpprreessssiioonn Example 1 Example 1 document.write(Exp(6.7)) document.write(Exp(6.7)) Output: Output: 812.405825167543 812.405825167543 Example 2 Example 2 document.write(Exp(-6.7)) document.write(Exp(-6.7)) Output: Output: 1.23091190267348E-03 1.23091190267348E-03 13.5. Hex 13.5. Hex

The Hex function returns a

The Hex function returns a string that represents the hexadecimal value of a string that represents the hexadecimal value of a specifiedspecified number.

number. Note:

Note: If number is not already a whole If number is not already a whole number, it is rounded to the nearest whole number number, it is rounded to the nearest whole number   before being evaluated.

 before being evaluated.

Page 31 of 69 Page 31 of 69

References

Related documents

Therefore, punching shear can be defined as a failure of the slab in that area where the load is applied in high intensity, or due to shear stress at the column support region,

With the help of the Tams-Witmark collection, housed at the University of Wisconsin-Madison’s Mills Music Library special collections, this paper will examine how two of these

ƒ In many cases, content creation is given to the department or person who created the account, with the agency's public information officer being responsible for ensuring

 Primerden akan akım sıfır olur  Olay sonucunda primer sargıya normalinden çok daha yüksek bir gerilim düşer  Trafo doyar  Sekonder gerilimi yükselir

This conclusion is further supported by the following observations: (i) constitutive expression of stdE and stdF in a Dam + background represses SPI-1 expression (Figure 5); (ii)

Hercules passenger car tires which become unserviceable because of the following conditions are excluded from Limited Warranty coverage and are not subject to adjustment: tires run

H3: Multinationals’ diversity of prior international experience will flatten the inverted U-shaped relationship between speed of internationalization and long-term

Humaira, titled “Hacker Personality Profiles Reviewed in Terms of the Big Five Personality Traits,” examined the personality types of three hacker groups; the white hats who hack