Web Hosting Canada
Canadian Web Hosting  
ASP Hosting  
Call Toll-Free 1-866-421-8886  
 ASP.NET Support
DEVELOPER RESOURCES


 • 
Technetex Canada


 • 
Support Website


 • 
Forums


 • 
Dev Resources


ASP


 • 
ASP Reference Index


 • 
Built-in ASP Objects


 • 
Other ASP Objects


 • 
VBScript Reference


 • 
Links


 

   
 
VBScript Functions page 2 previous | next
 

This will provide you with a quick look at the more important VBScript functions. They include functions for type checking, type casting, formatting, math, date manipulation, string manipulation, and more.

 
Date Functions

These functions deal with the manipulation of date values.

Date returns the current date on the server.

Time returns the current time on the server.

Now returns the current date and time on the server.

Year(date) returns the year portion from date as a number.

Month(date) returns the month portion from date as a number.

MonthName(date) returns the month portion from date as a name.

Day(date) returns the day portion from date as a number.

Weekday(date) returns the day of the week of date as a number.

Hour(time) returns the hour portion from time.

Minute(time) returns the minute portion from time.

Second(time) returns the second portion from time.

DateAdd(interval, number, date) is used to add the date specified by date.
  interval is a string that represents whether you want to add days, months, years, and so on.
  number indicates the number of intervals you want to add.

DateDiff(interval, date1, date2, firstDOW, firstWOY) is used to find the time between two dates.
interval is one of the interval values from the table below. DateDiff returns the number of intervals elapsed between date1 and date2. The optional integer firstDOW specifies what day of the week to treat as the first. [See table] The optional firstWOY specifies which week of the year to treat as the first. [See table]

DateSerial(year, month, day) takes the integers year, month, and day and puts them together into a date value. They may be negative.

TimeSerial(hour, minute, second) takes the integers hour, minute, and second and puts them together into a time value. They may be negative.

Timer returns the number of seconds elapsed since midnight.

DatePart(interval, datetime, firstDOW, firstWOY) allows you to retreive the part of datetime specified by interval. The valid values for interval are listed in the table below. The optional integer firstDOW specifies what day of the week to treat as the first. [See table] The optional firstWOY specifies which week of the year to treat as the first. [See table]

 
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
Day of the Week Constants
  Value Name Meaning
  0 vbUseSystem National Language Support API Setting
  1 vbSunday Sunday
 

2

vbMonday Monday
  3 vbTuesday Tuesday
  4 vbWednesday Wednesday
  5 vbThursday Thursday
  6 vbFriday Friday
  7 vbSaturday Saturday
 
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 new year
  3 vbFirstFullWeek First full week
 
Top
String Functions

These functions allow you to manipulate string data.

UCase(string) returns string with all lowercase letters converted to uppercase letters.

LCase(string) returns string with all uppercase letters converted to lowercase letters.

LTrim(string) removes all the spaces from the left side of string.

RTrim(string) removes all the spaces from the right side of string.

Trim(string) removes spaces from both the left and the right sides of string.

Space(number) returns a string consisting of number spaces.

String(number, character) returns a string consisting of character repeated number times.

Len(string) returns the number of characters in string.

Len(variable) returns the number of bytes required by variable.

LenB(string) returns the number of bytes required to store string.

StrReverse(string) returns string with the characters in reverse order.

StrComp(string1, string2, comparetype) is used to perform string comparisons. If comparetype is zero or omitted, the two strings are compared as if uppercase letters come before lowercase letters. If comparetype is one, the two strings are compared as if uppercase and lowercase letters are the same. StrComp returns -1 if string1 is less than string2. It returns 0 if they are the same, and 1 if string1 is greater than string2.

Right(string, number) returns the number rightmost characters of string.

RightB(string, number) works like Right, but number is taken to be a number of bytes rather than characters.

Left(string, number) returns the number leftmost characters of string.

LeftB(string, number) works like Left, but number is taken to be a number of bytes rather than characters.

Mid(string, start, length) returns length characters from string, starting at position start. When length is greater than the number of characters left in the string, the rest of the string is returned. If length is not specified, the rest of the string starting at the specified starting position is returned.

MidB(string, start, length) works like Mid, but start and length are both taken to be byte numbers rather than character numbers.

Instr(start, string1, string2, comparetype) is used to check if and where string2 occurs within string1. start is an optional argument that specifies where in string1 to start looking for string2. comparetype is an optional argument that specifies which type of comparison to perform.
If comparetype is 0, a binary comparison is performed - uppercase are distinct from lowercase.
If comparetype is 1, a textual comparison is performed - uppercase and lowercase are the same.
Instr returns zero if srting1 is empty (""), if string2 is not found in string1, or if start is greater than the length of string2. It returns Null if either string is Null. It returns start if string2 is empty. If string2 is successfully found in string1, it returns the starting position where it is first found.

InstrB works the same as Instr except that the start position and return value are byte positions, not character positions.

Instr(start, string1, string2, comparetype) starts looking for a match at the right side of the string rather than the left side. start is by default -1, which means to start at the end of the string.

Replace(string, find, replace, start, count, comparetype) is used to replace occurences of find with replace in string. start, count, and comparetype are optional, but if you want to use one, you must use the ones that come before it. start indicates where the resulting string will start and where to start searching for find. It defaults to 1. count indicates how many times to perform the replacement. By default count is -1, which means to replace every occurence.
If comparetype is 0, a binary comparison is performed - uppercase are distinct from lowercase.
If comparetype is 1, a textual comparison is performed - uppercase and lowercase are the same.

Filter(arrStrings, SearchFor, include, comparetype) searches an array of strings, arrStrings, and returns a subset of the array. include is a Boolean value. If include is True, Filter searches through all the strings in arrStrings and returns an array containing the strings that contain SearchFor. If include is False, Filter returns an array of the strings that do not contain SearchFor. include is optional and defaults to True.
If comparetype is 0, a binary comparison is performed - uppercase are distinct from lowercase.
If comparetype is 1, a textual comparison is performed - uppercase and lowercase are the same.
If you want to use comparetype you must also use include.

Split(expression, delimiter, count, comparetype) takes a string and splits it into an array of strings. expression is the string to be split. If expression is zero length, Split returns an array of no elements. delimiter is a string that indicates what is used to separate the sub-strings in expression. This is optional; by default the delimiter is the space. If delimiter is zero length (""), an array of one element consisting of the whole string is returned. count is used to specify a maximum number of sub-strings to be created. The default for count is -1, which means no limit.
If comparetype is 0, a binary comparison is performed - uppercase are distinct from lowercase.
If comparetype is 1, a textual comparison is performed - uppercase and lowercase are the same.
comparetype is only useful when the delimiter you have chosen is a letter.

Join(stringarray, delimiter) does just the opposite of Split. It takes an array of strings and joins them into one string, using delimiter to separate them. delimiter is optional; space is the default.

Top
Other Functions
 

LBound(array) returns the smallest valid index for array.

UBound(array) returns the largest valid index for array.

Asc(string) returns the ANSI character code for the character of string.

Chr(integer) returns a string consisting of the character that matches the ANSI character code specified by integer.

Array(value1, value2, ..., valueN) returns an array containing the specified values. This is an alternative to assigning the values to array elements one at a time.

  Top
 
Logo
2004 © Technetex
Protected by Copyright. All Rights Reserved.