VBScript Quick Reference Guide By: Mike Sparr (asp.mikesparr.com)

True		= -1				False		= 0
Chr(13)		= Carriage Return		Chr(10)		= Line Feed

Option Explicit : use when only declared variables can be used (Top)

Create Variants (Top)
	DIM strDirectory, intValue, , datCurrent, a_strArray, rsRecordSet, objDictionary

Variable Checking Functions (Top)
	IsArray(varname)			IsNumeric(expression)
	IsDate(expression)			IsObject(expression)
	IsEmpty(expression)			VarType(varname) - See Below
	IsNull(expression) - use instead of If Var = Null or <> Null

VarType Return values (Top)
	Empty		= 0			String			= 8
	Null		= 1			Auto object		= 9
	Integer		= 2			Error			= 10
	Long Integer	= 3			Boolean			= 11
	Single-Pr FPN	= 4			Variant			= 12
	Double-Pr FPN 	= 5			Non-auto obj		= 13
	Currency	= 6			Byte			= 17
	Date		= 7			Array			= 8192

Array Functions (Top)
	Redim 	(redefine the array dimension)
	LBound 	(returns 0, the default lower bound for any array)
	UBound	(determines the upper limit of an array: use with Loops)
	Erase	(erases a designated array and frees up storage)

Ouputting mathematical values (Top)
	Response.Write 6 * 3  use \ for integer division

Logical Operators (Not, And, Or, Xor, Eqv, Imp, &) (Top)

Looping and Decision Structures (see example pages) (Top)
	If/Then/Else (If condition Then action1 Else action2 EndIf)
	For/Next (For var = num To num Step 1 / Next var)
	Select/Case (Like CFSwitch)
	Do/Loop
	While/Wend

VBScript Functions: Number Conversions (useful for db/datasource types) (Top)
	CBool		(boolean: returns true any nonzero number)
	CByte		(1-255, converts to byte)
	CCur		(currency: 4 digits out)
	CDate		(Date: numeric; see also: FormatDateTime)
	CDbl		(Double: ** Largest capacity data type ** )
	CInt		(Integer)
	CLng		(Long Integer)
	CSng		(Single - empty causes error!)
	CStr		(Takes any expression & converts to string)

Data Formatting Functions (Top)
	FormatCurrency(Expression,numdigits,inclLeadingDigit,parens4negatives,groupDigits)
		FormatCurrency(1.231)				= $1.23
		FormatCurrency(1.231,3)				= $1.231
		FormatCurrency(0.523,2)				= $ .52
		FormatCurrency(0.523,2,-1)			= $0.52
		FormatCurrency(-23520.523,2,,-1,-1)		= ($23,520.52)
	FormatDateTime(Date,NamedFormat)
		NamedFormat Parameter Values
			0	=	Displays date and/or time (whatevers present)
			1	=	Displays date using long format in reg. settings
			2	=	Displays date using short format in reg. settings
			3	=	Displays time using format in reg. settings
			4	=	Displays time using the 24-hour format (hh:mm)
	FormatNumber(same as FormatCurrency except no $ signs)
	FormatPercent(same as FormatCurrency except % sign added and multiplied by 100)
	
Text Manipulation Functions (Top)
	Filter		(expression: usually an array,"criteria",-1:in / 0:not in,1:text/binary)
	InStr		(looks for a string within another, returns 0 or location from beginning)
	InStrRev	(same as above except searches from end)
	Join		(opposite of split - grabs array values and makes single string)
	LCase		(converts all letters to lowercase)
	Left		(returns specified number of chars. from beginning of string)
			i.e. - Left("Some Term",4) returns: Some
	Len		(returns the length of a string: all chars including non-printing)
	LTrim		(removes spaces from the beg. of string)
	Mid		(returns specified num. of chars. in string beginning at a given point)
	Replace		("Text String", "String", "Length") returns: Text Length
	RTrim		(removes spaces from the end of string)
	Space		(create string of spaces) - Space(50) returns: 50 spaces
	Split		(break apart a string into an array based on a specified delimiter character)
	StrReverse	(reverses a string: thats it!)
	String		(outputs specified string for given spaces) - String("-",20) ret: (20) ---
	Trim		(removes spaces from beginning and end of string)
	UCase		(converts all letters to uppercase)
	
Date and Time Format Argument Strings (Top)
	Year		= yyyy			Weekday			= w
	Quarter year	= q			Week of year		= ww
	Month		= m			Hour			= h
	Day of year	= y			Minute			= m
	Day		= d			Second			= s
	
Date and Time Functions (Top)
	Date		(returns the current date)
	DateAdd		(adds dates together: can increment/decrement dates)
			i.e. - datFuture = DateAdd("d", 30, datCurrent) - 30 days in the future
	DateDiff	(returns the difference between dates after specifying unit of time)
			i.e. - Response.Write DateDiff("yyyy", #1/1/1999#, #1/1/2000#) - returns 1
	DatePart	(returns the specified unit of time for a date variable)
			i.e. - Response.Write DatePart("ww", Date) - ret: week of yr. of "Date" var.
	DateSerial	(creates a date based on integer year, month, and day valuse.
			i.e. - datCurrent = DateSerial(2000, 5, 30)
	DateValue	(converts string value to date - assumes no year specified is curr. year)
	Day		(returns day of the month given valid date variable)
	Hour		(returns the hour of the day " " )
	Minute		(returns the minute of the hour " " )
	Month		(returns the month of the year " " )
	MonthName	(returns the regional name of month: 1 = January, etc.)
	Now		(returns both current date and time)
	Second		(returns the second of the minute " " )
	Weekday		(returns the weekday number: Sunday = 1, etc.)
	WeekdayName	(returns the regional name of the weekday: 1 = Sunday, etc.)
	Year		(returns the year of the date given, " " )
	
Built-In Objects (Top)
	Dictionary Object (essentially a lookup table: each "row" has a key and a value)
		Set objDictionary = Server.CreateObject("Scripting.Dictionary")
		objDictionary.Add "MSFT", "Microsoft Corporation"
		objDictionary.Add "DELL", "Dell Computer Corporation"
		Response.Write objDictionary("DELL") returns: Dell Computer Corporation
	Err Object (used in error handling)
	FileSystemObject (allows performing file operations)

Server Side Includes (there are many, but these are useful) (Top)
	Last Modified	<!--#flastmod file="somefile.htm" -->
	File Size	<!--#fsize file="somefile.htm" -->
	Include		<!--#include file="somefile.htm" --> or
			<!--#include virtual="/dir/somefile.htm" -->
	
Request Object (Request.[option]) (Top)
	Cookies			(gathers variables from cookies folder)
	Form			(gathers variables from form submission)
	QueryString		(gathers variables from URL string: ?var=someVal)
	ServerVariables 	(Request.ServerVariables("[option]") - see below
		ALL_HTTP				AUTH_TYPE
		AUTH_PASSWORD				AUTH_USER
		CONTENT_LENGTH				CONTENT_TYPE
		DOCUMENT_NAME				DOCUMENT_URI
		DATE_GMT				DATE_LOCAL
		GATEWAY_INTERFACE			LAST_MODIFIED
		PATH_INFO				PATH_TRANSLATED
		QUERY_STRING				QUERY_STRING_UNESCAPED
		REMOTE_ADDR				REMOTE_HOST
		REMOTE_USER				REQUEST_METHOD
		SCRIPT_NAME				SERVER_NAME
		SERVER_PORT				SERVER_PORT_SECURE
		SERVER_PROTOCOL				SERVER_SOFTWARE
		URL
	BinaryRead 		(new! - allows uploads from client)
	
Response Object (Response.[option]) (Top)
	CacheControl 		(private/public: det. where caching will occur)
	Clear			(empties the buffer of any text)
	ContentType		(changes content type: tells browser what to do w/ info.)
	End			(stops running the page)
	Expires			(when cached page will expire: in minutes)
	ExpiresAbsolute		(set date/time when expires: #5/15/00 11:00 AM#)
	Flush			(forces all the txt in buffer to user's browser window)
	IsClientConnected	(tells if user is still connected - use with long operations)
	Redirect		(redirects to another url: response.redirect "page.asp")
	Write			(creates output: response.write "something")
	
Cookies (Top)
	Writing a Cookie	Response.Cookies("LastVisit") = Date & " " & Time
	Setting Expiration	Response.Cookies("LastVisit").Expires = DateAdd("d", 1, Date)
	Reading a Cookie	Request.Cookies("LastVisit")