VBScript Functions 
Type Checking  Typecasting  Formatting


Type Checking Functions 

Value 
Constant 
Data Type 

0 
vbEmpty 
Empty [This is the type for a variable that has yet to be used, and


1 
vbNull 
Null [no valid data] 

2 
vbInteger 
Integer 

3 
vbLong 
Long 

4 
vbSingle 
Single 

5 
vbDouble 
Double 

6 
vbCurrency 
Currency 

7 
vbDate 
Date 

8 
vbString 
String 

9 
vbObject 
Object 

10 
vbError 
Error 

11 
vbBoolean 
Boolean 

12 
vbVariant 
Variant [used with vbArray] 

13 
vbDataObject 
Data Access Object 

14 
vbDecimal 
Decimal 

17 
vbByte 
Byte 

8192 
vbArray 
Array [VBScript uses 8192 as a base for arrays and adds the code for


TypeName(expression) returns a



IsNumeric(expression) returns a



IsArray(expression) returns a



IsDate(expression) returns a



IsEmpty(expression) returns a



IsNull(expression) returns a



IsObject(expression) returns a


Typecasting Functions 

Cint(expression) casts


Cbyte(expression) casts


Cdbl(expression) casts


Csng(expression) casts


Cbool(expression) casts


Ccur(expression) casts


Cdate(expression) casts


Cstr(expression) casts


Formatting Functions 

FormatDateTime(expression, format)


FormatCurrency(value, numdigits, leadingzero, negparen, delimiter)


FormatNumber is used to format


Math Functions 

Abs(number) returns the absolute


Atn(number) returns the


Cos(number) returns the cosine of


Exp(number) returns e (approx.


Fix(number) returns the integer


Hex(number) converts


Int(number) returns the integer


Log(number) returns the natural


Oct(number) converts


Rnd number returns a random number


Randomize initialises the random


Round(number) returns


Round(number, dec) returns


Sgn(number) returns 1 if


Sin(number) returns the sine of


Sqr(number) returns the square


Tan(number) returns the tangent of


Date Functions 

Date returns the current date on


Time returns the current time on


Now returns the current date and


Year(date) returns the year


Month(date) returns the month


MonthName(date) returns the month


Day(date) returns the day portion


Weekday(date) returns the day of


Hour(time) returns the hour


Minute(time) returns the minute


Second(time) returns the second


DateAdd(interval, number, date) is


DateDiff(interval, date1, date2, firstDOW, firstWOY)


DateSerial(year, month, day) takes


TimeSerial is similar to


Timer returns the number of


DatePart(interval, datetime, firstDOW, firstWOY)

Table 1: Interval codes for the Date Functions 


Value 
Meaning 


"yyyy" 
Year 


"q" 
Quarter 


"m" 
Month 


"y" 
Day of year 


"d" 
Day 


"w" 
Weekday 


"ww" 
Week of year 


"h" 
Hour 


"n" 
Minute 


"s" 
Second 
Table 2: Day of the Week Constants 


Value 
Name 
Meaning 

0 
vbUseSystem 
National Language Support API Setting 

1 
vbSunday 
Sunday (default) 

2 
vbMonday 
Monday 

3 
vbTuesday 
Tuesday 

4 
vbWednesday 
Wednesday 

5 
vbThursday 
Thursday 

6 
vbFriday 
Friday 

7 
vbSaturday 
Saturday 
Table 3: First Week of the Year Constants 


Value 
Name 
Meaning 

0 
vbUseSystem 
National Language Support API Setting 

1 
vbFirstJan1 
Week of January 1 

2 
vbFirstFourDays 
First week with four days of the new year 

3 
vbFirstFullWeek 
First full week 

String Functions 

UCase(string) returns


LCase(string) returns


LTrim(string) removes all the


RTrim(string) removes all the


Trim(string) removes spaces from


Space(number) returns a string


String(number, character) returns


Len(string) returns the number of


Len(variable) returns the number


LenB(string) returns the number of


StrReverse(string) returns


StrComp(string1, string2, comparetype)


Right(string, number) returns the


RightB(string, number) works like


Left(string, number) returns the


LeftB(string, number) works like


Mid(string, start, length) returns


MidB(string, start, length) works


InStr(start, string1, string2, comparetype)


InStrB works like


InStrRev(string1, string2, start, comparetype)


Replace(string, find, replace, start, count, comparetype)


Filter(arrStrings, SearchFor, include, comparetype)


Split(expression, delimiter, count, comparetype)


Join(stringarray, delimiter) does


Other Functions 

LBound(array) returns the smallest


UBound(array) returns the largest


Asc(string) returns the ANSI


Chr(integer) returns a string


Array(value1, value2, ..., valueN)

No comments:
Post a Comment