The description Each of the frames of this document is created with the help by last version of the designer "Michael" and demonstrates opportunities of the designer.
Purpose This operative help on VBS is intended for application and study of language of the scripts VBS. The application of language is carried out by an insert of fragments of language and examples in the text of the edited script and illustrative performance of examples. For study of language the elements of language, fragments, examples and comment are given.
The order of application
Opening of this window This window will be opened under following conditions:
When on a field of the designer the window of editing of the script, or HTML-code is opened;
And when is marked left of radio-switches;
And when the cursor of the mouse is placed on a place of an insert of a fragment or example;
And when is pressed on the keyboard "Alt";
And when the click on a place of an insert is made.
The description of a window Before you a window. It consists of 3 frames:
The top frame is intended for return to the looken up topics. For transition on the looken up topics forward or back under the list, click buttons "forward", "back". For any transition open the list and click the necessary topic.
The left frame contains topics as the list. By search, viewing choose the topic, necessary to you, and click it. The topic will appear in the right frame and its heading will be inserted into the list of the looken up topic.
Right frame represents the contents of topics. Each topic can contain the references to other topics. Click the underlined black text and there will be a necessary topic, and its heading will be inserted into the list of the looken up topics. For inclusion of a topic in the list of the looken up topics, with viewing in the right frame by scrolling, click heading of a topic.
Insert of fragments and examples in the script The elements of language ready to an insert in the script are submitted as dark blue italic. For their insert click under them. The examples, which can be inserted into the text of the script, are placed in frameworks. The idea about application of fragments and examples in practical programming and study of language is, that you insert them into the text of your script and correct them so that they corresponded to that is necessary.It means: change of names variable, replacement of constant and other.
Illustrative performance of examples To be sure that the examples work, and to look results of this work, and to estimate them, the practical examples are given. Their texts are placed in frameworks. For performance of an example place the cursor inside of a framework and press "Enter". The example will be executed. Estimate results. If they correspond to needs of your script, place the cursor inside of a framework and click. The text of an example will be inserted into the text of the edited script.
Note Some examples in frameworks are given only for an insert. The place of click for an insert is marked by a symbol ¶. Do not trouble itself with removal of this symbol, it is erased automatically.
The tag SCRIPT
All texts of the scripts should be inside this script, if you work in a window of editing of "head" or scripts of object "HTML". Thus the insert of the scripts - codes in the text SCRIPT is carried out automatically. The texts of the scripts of processing of events can be in scripts.
Examples of the tag:
PROCEDURES VBS:
Procedures ~ functions VBS;
Procedures ~ subroutines VBS.
By word "Rem" the comments in the texts of examples begin.
Procedures ~ functions VBS
It is the programs which are carrying out certain actions, and called repeatedly from various parts of the different scripts, by transfer of initial parameters and return of value.
Without parameters
The description
Call dev1()
With parameters
The description
Call dev5=dev1(1,2)
Procedures ~ subroutines VBS
It is the programs the carrying out certain actions and called repeatedly from various parts of the different scripts.
The description
Call dev1, or more evidently Call dev1
Rules for names of variable
Should begin with the letter.
Should not contain blanks.
To be unique in the area of application.
There should not be more than 256 symbols.
The register of symbols in a name has not meaning. Dev1 and DEV1 this reference to same variable.
Should not coincide with names of the code of the designer, for it in this manual all variable begin with symbols DEV.
Types of the data
In VBS there is only one type of the data - variant. There are following subtypes of variant:
Empty - Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables.
Null - Variant intentionally contains no valid data.
Boolean - Contains either True or False.
Byte - Contains integer in the range 0 to 255.
Integer - Contains integer in the range -32,768 to 32,767.
Currency - from -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
Long - Contains integer in the range -2,147,483,648 to 2,147,483,647.
Single - Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
Double - Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
Date(Time) - Contains a number that represents a date between January 1, 100 to December 31, 9999.
String - Contains a variable-length string that can be up to approximately 2 billion characters in length.
The reference is the index on object, with which help the access to properties, methods and collections of objects is carried out. Details look " The operative help on HTML ".
Assignment: Set Name_variable = object
Removal: Set Name_variable=Nothing EXAMPLE - to receive the reference to the first object of the document and to cancel it:
Scope
All variable, which are defined obviously (Dim) or implicitly (without Dim, assignment of value), outside of the subroutines, or functions are global. Variable, which do not coincide on a name with global and are defined obviously, or is implicit, inside the subroutine or the functions work only inside them.
Arrays
The size arrays up to 60.
To define static one-dimensional array with 10 elements Dim Dev1 (9) Assigment of value to elements of the array: Dev1(0)=1 ... Dev1(9)=10
Definition of dynamic arrayDim Dev1()
Change of the size of a dynamic array: ReDim Dev1(100)
Change of the size dynamic array by preservation of values of its elements: ReDim Preserve Dev1(100,100)
To change the size of a dynamic array the unlimited number of time is possible.
Functions of array
CONSTANTS:
Empty - value which variable at is not present value;
Nothing - value of a variable type of the reference on object with the cancelled reference;
Null - value of variable, value is incorrect;
True - the value of a variable logic type, which value is true;
False - the value of a variable logic type, which value is false;
vBObjectError -constant of errors;
Constants of system colours;
Constants of comparison;
Constants of date and time;
Constants of formats of date and time;
Constants of formats of date and time;
Textual constants;
Constants logic;
Constants of a subtype variable.
Constants of system colours
vbBlack or &h00 - Black
vbBlue or &hff0000 - Blue
vbRed or &hff - Red
vbMagenta or &hff00ff - Magenta
vbGreen or &hff00 - Green
vbCyan or &hffff00 - Cyan
vbYellow or &hffff - Yellow
vbWhite or &hffffff - White
Constants of comparison
vbBinaryCompare or 0 - Carries out comparison of binary numbers
vbTextCompare or 1 - Carries out comparison of the text
vbDatabaseCompare or 2 - Carries out comparison of that part of the information in a database, where was applied.
Constants of date and time
vbSunday or 1 - Sunday.
vbMonday or 2 - Monday.
vbTuesday or 3 - Tuesday.
vbWednesday or 4 - Wednesday.
vbThursday or 5 - Thursday.
vbFriday or 6 - Friday.
vbSaturday or 7 - Saturday.
vbFirstJan1 or 1 - The week in which has come on January 1 of current year.
vbFirstFourDays or 2 - The first week, in which was as a minimum 4 days of new year.
vbFirstFullWeek or 3 - The first complete week of year.
vbUseSystem or 0 - Use of a format of installations of date and time accepted for this computer.
vbUseSystemDayOfWeek or 0 - First day, used on the computer, of week.
Constants of formats of date and time
vbGeneralDate or 0 - Date and - or time in a format accepted on the computer. For material numbers specifies date and time. For integers - only date. For numbers, which on value < 1, the time specifies only.
vbLongDate or 1 - Date in a complete format accepted on the computer.
vbShortDate or 2 - Date in a brief format accepted on the computer.
vbLongTime or 3 - Time in a complete format accepted on the computer.
vbShortTime or 4 - Time in a brief format accepted on the computer.
Textual constants
vbCr or chr(13) - Return of the carriage.
vbCrLf or Chr(13)&Chr(10) - Return of the carriage.
vbLf or chr(13) - Carry of a line.
vbNewLine - Carry of a line on the given platform.
vbNullChar or Chr(0) - Symbol value is 0.
vbNullString - String with zero value.
vbTab or Chr(9) - Return of the carriage.
Constants logic
True or -1
False or 0
Constants of a subtype variable
vbEmpty or 0 - Is not determined (by default).
vbNull or 1 - Does not contain the correct data.
vbInteger or 2 - Integer.
vbLong or 3 - Long integer.
Single or 4 - Single-precision floating-point number.
vbDouble or 5 - Double-precision floating-point number.
vbCurrency or 6 - Money format of number.
vbDate or 7 - Format of date.
vbString or 8 - Textual variable.
vbObject or 9 - The reference to object.
vbError or 10 - Error.
vbBoolead or 11 - Logic variable.
vbVariant or 12 - Attribute (only for a array of attributes).
vbDataObject or 13 - Object for access to the data.
vbDecimal or 14 - Decimal number.
vbByte or 17 - Byte.
vbArray or 8912 - Array.
The subtype of a constant can be learned by the following function: VarType("It is textual variable, constant of a kind=vbString or 8.")
The arithmetic operators
^, R = N ^ S, raises a N to the power of an S, if N < 0, S should be an integer. N = Empty equivalently N = 0, S = Empty equivalently S = 0.
*, R = M*N, multiplies M on N, M = Empty equivalently M = 0, N = Empty equivalently N = 0.
/, R=M/N - Divides M on N. M = Empty equivalently M = 0, N = Empty equivalently N = 0.
\, R = M\N, integer divide, M and N before divide up to an integer is approximated, then M is divided on N, the fractional part is rejected also this result R is given. M = Empty equivalently M = 0, N = Empty equivalently N = 0.
Mod, R = M MOD N, Before to divide M on N, they are approximated up to an integer, then M is divided on N. The rest from division is given R. M = Empty equivalently M = 0, N = Empty equivalently N = 0.
+,R = M + N, sum of two numbers. M = Empty equivalently M = 0, N = Empty equivalently N = 0.
-, R=M-N, R = -M, difference of two numbers or change of a mark on opposite. M = Empty equivalently M = 0, N = Empty equivalently N = 0.
The operators of comparison
The list of the operators of comparison and condition, with which the result has value: true,false,null
operators
True
False
Null
<, less
x<y
x>=y
x or y=Null
<=, less or equal
x<=y
x>y
x or y=Null
>, more
x>y
x<=y
x or y=Null
>=, more or equal
x>=y
x<y
x or y=Null
=, equal
x=y
x<>y
x or y=Null
<>, not equally
x<>y
x=y
x or y=Null
THE RECOMMENDATION: With an insert of the script - code in object HTML, in the tag SCRIPT, do not use the operators of comparison < and >, in exchange use and <= and >=. It will allow an insert to work correctly.
The operator of merge of the texts & - is used for merge of two textual expressions.
THE MANAGING OPERATORS:
THE OPERATORS OF BRANCHING:
If,,,Then;
If,,,Then,,,Else;
If,,,Then,,,ElseIf;
Select Case.
THE OPERATORS OF CYCLES:
Do While,,,Loop;
Do Until,,,Loop;
Do,,,Loop While;
Do,,,Loop Until;
While,,,Wend;
For,,,Next.
For Each,,,Next
THE OPERATORS OF BRANCHING:
If,,,Then;
If,,,Then,,,Else;
If,,,Then,,,ElseIf;
Select Case.
If,,,Then if condition then operators, If a condition "true" to execute "operators", if is "false" nothing to do. EXAMPLE 1 - to print the message, applying the operator in one line:
EXAMPLE 2 - to print the message, applying the operator in some line:
If,,,Then,,,Else if condition then operators_1 else operators_2 end if , If the condition is true that to execute "operators _ 1 ", if the condition is false to execute "operators _ 2 ". EXAMPLE - variable to give a logic kind, if value of variable is true, to give out "The expression is true ",otherwise to give out "The expression is false":
If,,,Then,,,ElseIf if condition_1 then operators_1 elseif condition_2 then operators_1 elseif condition_3 then operators_1 ... else operators_N end if, If "condition_1" is true, that to execute "operators_1", if "condition_1 " is false to check up "condition _ 2". If "condition_2" is true to execute "operators_2", if "condition_2" false, to check up "condition_3", and so on. If any of conditions not "true" to execute "operators_N" EXAMPLE - variable to give value, to analyse value on entry in intervals and >= 10, and < = 7 and to give out result of the analysis:
Select Case Select case condition DEVY case expression1 operators_1 case expression2,expression3 operators_2 ... case else operators_N end select, The value of expression DEVY is calculated, for an explanation we shall name this value ZDEVY. ZDEVY is compared to value "expression1", if they are equal, the "operators_1" are carried out and the work comes to an end. If not are equal that, is compared to values "expression2" and "expression3". If ZDEVY is equal to one of compared values, the "operators_2" are carried out and the work comes to an end, if not are equal, the comparisons ZDEVY with one, or several values of expressions in the following line and so on are carried out. If ZDEVY was not compared to one value of expression in the subsequent lines case, the "operators_N" are carried out and the work comes to an end, EXAMPLE - to analyze value of variable and to give out the different messages with performance of the following conditions: value of variable = 1; value of variable = 2 or 3; value of variable not equally 1, 2, 3:
THE OPERATORS OF CYCLES:
Do While,,,Loop;
Do Until,,,Loop;
Do,,,Loop While;
Do,,,Loop Until;
While,,,Wend;
For,,,Next;
For Each,,,Next.
Do While,,,Loop do while condition operators loop , To carry out the operators while "condition" has value "true", if the condition has value "false", the cycle can not be executed of any time. The operands determining a condition, should change in a cycle so, that there was a correct exit from a cycle, differently case the infinite cycle will be organized. If the script is carried out suspiciously long, one of the reasons it is the organization of an infinite cycle. In this case , finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle. EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
Do Until,,,Loop do until condition operators loop. To carry out "operators" while a condition will not become "true". If the condition has value "true", the cycle can not be executed of any time. The operands determining a condition, should change in a cycle so, that there was a correct exit from a cycle, differently case the infinite cycle will be organized. If the script is carried out suspiciously long, one of the reasons it is the organization of an infinite cycle. In this case , finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle. EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
Do,,,Loop While do operators loop while condition . To execute "operators" to check up a condition and, if it has value "true" to execute "operators". Further to work so, while "condition" has value "true". The cycle will be executed as a minimum once. The operands determining a condition, should change in a cycle so, that there was a correct exit from a cycle, differently case the infinite cycle will be organized.If the script is carried out suspiciously long, one of the reasons it is the organization of an infinite cycle. In this case , finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle. EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
Do,,,Loop Until do operators loop until condition. To execute "operators" to check up "condition" and, if it has value "false" to execute "operators". Further to work so, while "condition" has value "false".The cycle will be executed as a minimum once. The operands determining a condition, should change in a cycle so, that there was a correct exit from a cycle, differently case the infinite cycle will be organized.If the script is carried out suspiciously long, one of the reasons it is the organization of an infinite cycle. In this case , finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle. EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
As against DoWhile,,, Loop under any condition will be executed once.
While,,,Wend while condition operators wend To carry out "operators" while "condition" has value "true".The operands determining a condition, should change in a cycle so, that there was a correct exit from a cycle, differently case the infinite cycle will be organized. If the script is carried out suspiciously long, one of the reasons it is the organization of an infinite cycle. In this case , finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle. EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
For,,,Next FOR variable_cycle = initial_value TO final_value STEP step_changes_variable_cycle operators next. To carry out "operators" while "variable_cycle" the value will not reach "final_value". "Variable_cycle" the value up to "final_ alue" with a step "step_changes_variable_cycle" changes automatically from "initial_value". EXAMPLE - to execute a cycle 3 times giving out the message with each performance:
For Each,,,Next FOR EACH the reference _ on _ object IN a collection operators next. For each object from a "collection" to execute the "operators". EXAMPLE - to see all objects "button" in the document and to show for each object its number and beginning of a html-code:
FUNCTIONS VBS:
FUNCTIONS OF ARRAY;
FUNCTIONS OF TRANSFORMATION;
FUNCTIONS OF DATE AND TIME;
MATHEMATICAL FUNCTIONS;
CODES OF THE ENGINE;
TEXTUAL FUNCTIONS.
FUNCTIONS OF ARRAY:
FUNCTIONS OF TRANSFORMATION:
Asc
AscB
AscW
Chr
ChrB
ChrW
CBool
Cbyte
CDbl
Cint
Clng
CStr
CSng
Fix
Hex
Int
Oct
Sgn
Round
Asc Asc(string) - Returns the ANSI character code corresponding to the first letter in a string. The string argument is any valid string expression. If the string contains no characters, a run-time error occurs.
AscB AscB(string) - returns the first byte in a sequence of bytes.The AscB function is used with byte data contained in a string.
AscW AscW(string) - Returns the Unicode (wide) character code, thereby avoiding the conversion from Unicode to ANSI.AscW is provided for 32-bit platforms that use Unicode characters.
Chr Chr(charcode) - returns the character associated with the specified ANSI character code.The charcode argument is a number that identifies a character.
ChrB ChrB(charcode) - returns byte on a charcode. The ChrB function is used with byte data contained in a string.
ChrW ChrW(code) - returns a code wide transformed into ANSI code.ChrW is provided for 32-bit platforms that use Unicode characters. Its argument is a Unicode (wide) character code, thereby avoiding the conversion from ANSI to Unicode.
CBool CBool(expression) - Returns an expression that has been converted to a Variant of subtype Boolean. The expression argument is any valid expression.
Cbyte Cbyte(expression) - Returns an expression that has been converted to a Variant of subtype Byte. The expression argument is any valid expression.
CDbl CDbl(expression) - Returns an expression that has been converted to a Variant of subtype Double.The expression argument is any valid expression.
Cint Cint(expression) - Returns an expression that has been converted to a Variant of subtype Integer. The expression argument is any valid expression.
Clng Clng(expression) - Returns an expression that has been converted to a Variant of subtype Long.The expression argument is any valid expression.
CStr CStr(expression) - Returns an expression that has been converted to a Variant of subtype String. The expression argument is any valid expression
CSng CSng(expression) - Returns an expression that has been converted to a Variant of subtype Single.The expression argument is any valid expression.
Fix Fix(number) - returns the integer portion of a number. The number argument can be any valid numeric expression. If number contains Null, Null is returned.
Hex Hex(number) - Returns a string representing the hexadecimal value of a number. The number argument is any valid expression.
Int Int(number) - returns the integer portion of a number. The number argument can be any valid numeric expression. If number contains Null, Null is returned.
Oct Oct(number) - Returns a string representing the octal value of a number.The number argument is any valid expression.
Round Round(expression[, numdecimalplaces]) - Returns a number rounded to a specified number of decimal places.
Arguments:
expression - numeric expression being rounded.
numdecimalplaces - number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function.
Sgn Sgn(number) - Returns an integer indicating the sign of a number.The number argument can be any valid numeric expression.
FUNCTIONS OF DATE AND TIME:
Date
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
Hour
Minute
Month
MonthName
Now
Second
Time
TimeSerial
TimeValue
Weekday
WeekdayName
Date Date() - returns current system date.
DateAdd DateAdd(interval, quantity, date) - Rather "date"(variant or literal representing the date) returns date with addition or subtraction of "quantity" (numeric expression ) of temporary "interval"(string expression). The following value of an interval are allowed:
DateAdd("yyyy",1,"01.01.2000") - Year.
DateAdd("Q",1,"01.01.2000") - Quarter.
DateAdd("m",1,"01.01.2000") - Month.
DateAdd("y",1,"01.01.2000") - Day of year.
DateAdd("d",1,"01.01.2000") - Day of month.
DateAdd("w",1,"01.01.2000") - Day of week.
DateAdd("H",1,"01.01.2000 00:00:00") - Hours.
DateAdd("N",1,"01.01.2000 00:00:00") - Minutes.
DateAdd("S",1,"01.01.2000 00:00:00") - Seconds.
DateDiff DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])- Returns number of "interval"(string expression) between two dates "date1" "date2"(date expressions). The following values of an interval are allowed:
Parameter "firstdayofweek" unessential. It is a constant indicating the first day of week. The following value are allowed:
vbUseSystemDayOfWeek or 0 - Use National Language Support (NLS) API setting.
VbSunday or 1 - Sunday (by default).
VbMonday or 2 - Monday
VbTuesday or 3 - Tuesday.
VbWednesday or 4 - Wednesday.
VbThursday or 5 - Thursday.
VbFriday or 6 - Friday.
VbSaturday or 7 - Saturday
Parameter firstweekofyear unessential. It is a constant indicating the first week of year. The following values are allowed:
vbUseSystem or 0, Use National Language Support (NLS) API setting.
VbFirstJan1 or 1 The week, which contains on January 1 (by default).
VbFirstFourDays or 2 The first week, which contains at least four days of new year.
VbFirstFullWeek or 3 The first full week of year.
The additional items of information The function DateDiff is intended for definition of number of the specified time intervals between two dates. For example, with the help of this function it is possible to calculate number of days between two dates or number of weeks between current date and end of year. For calculation of number of days between dates date1 and date2 it is possible to use time intervals of a type day of year ("y") or day of month (" d "). If interval is set as day of week (" w "), the number of weeks between two dates returnes. If date1 corresponds to Monday, the number of Mondays between date1 and date2 is counted up. Thus of date2 is taken into account, and date1 is not present. If interval is set in weeks (" ww "), the function DateDiff returns number of calendar weeks between two dates, i.e. number of Sandays between date1 and date2. Thus the date date2 is taken into account (if to it there corresponds Sunday), and date1 is not present (even if to it there corresponds Sunday). If date1 defines date, more late, than date2, the negative value returns. Argument firstdayofweek influences calculations using time intervals of the type "w" and "ww". If the date is set as a literal of dates specified year becomes a constant component of date. However if the date consists in direct inverted commas (" "), and the year is omitted, with each calculation of expression of date in it the current year will be substituted. It allows to write a code, which can be used within several years. With comparison of dates on December 31 and January 1 of the next year function DateDiff for an interval of a type the year (" yyyy ") returns value=1, though the difference between dates makes only one day.
DatePart DatePart(interval, date[,firstdayofweek[, firstweekofyear]]) - Returns value of "interval"(string expression) for the given date "date"(date expression). The following value of an interval are admitted:
DatePart("yyyy","01.01.2001") - Year.
DatePart("Q","01.01.2001") - Quarter.
DatePart("m","01.01.2001") - Month.
DatePart("y","01.01.2001") - Day of year.
DatePart("d","01.01.2001") - Day of month.
DatePart("w","01.01.2001") - Day of week.
DatePart("H","01.01.2001 01:00:00") - Hourses.
DatePart("N","01.01.2001 01:01:00") - Minutes.
DatePart("S","01.01.2001 01:01:59") - Seconds.
Parameter firstdayofweek unessential. It is a constant indicating the first day of week. The following values are admitted:
vbUseSystemDayOfWeek or 0 - Use National Language Support (NLS) API setting.
VbSunday or 1 - Sunday (by default).
VbMonday or 2 - Monday.
VbTuesday or 3 - Tuesday.
VbWednesday or 4 - Wednesday.
VbThursday or 5 - Thursday.
VbFriday or 6 - Friday.
VbSaturday or 7 - Saturday.
Parameter firstweekofyear unessential. It is a constant indicating the first week of year. The following values are admitted:
vbUseSystem or 0, Use National Language Support (NLS) API setting.
VbFirstJan1 or 1 - The week, which contains on January 1 (by default).
VbFirstFourDays or 2 - The first week, which contains at least four days of new year.
VbFirstFullWeek or 3 - The first full week of year.
The additional items of information. The function DatePart is intended for definition of the specified component of date. For example, with the help of this function it is possible to define day of week or current hour. The argument firstdayofweek influences calculations using time intervals of the type "w" and "ww". If the date is set as a literal of dates specified year becomes a constant component of date. However if the date consists in direct inverted commas (" "), and the year is omitted, with each calculation of expression of date in it the current year will be substituted. It allows to write a code, which can be used within several years.
DateSerial DateSerial(year, month, day) - Returns a Variant of subtype Date for a specified year(number between 100 and 9999, inclusive, or a numeric expression.), month(numeric expression), and day(numeric expression).
DateValue DateValue(date) - Returns value of argument in a format Date.The date argument is normally a string expression representing a date from January 1, 100 through December 31, 9999. However, date can also be any expression that can represent a date, a time, or both a date and time, in that range. EXAMPLE
Day Day(date) - Returns from 1 up to 31 arguments such as date. The date argument is any expression that can represent a date. If date contains Null, Null is returned. EXAMPLE
Hour Hour(time) - Returns an integer between 0 and 23, inclusive, representing the hour of the day. The time argument is any expression that can represent a time. If time contains Null, Null is returned. EXAMPLE
Minute Minute(time) - Returns an integer between 0 and 59, inclusive, representing the minute of the hour. The time argument is any expression that can represent a time. If time contains Null, Null is returned. EXAMPLE
Month Month(date) - Returns an integer between 1 and 12, inclusive, representing the month of the year. The date argument is any expression that can represent a date. If date contains Null, Null is returned. EXAMPLE
MonthName MonthName(month[, abbreviate]) -Returns a string indicating the specified month. Arguments:
month - the numeric designation of the month. For example, January is 1, February is 2, and so on.
abbreviate - boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False, which means that the month name is not abbreviated.
EXAMPLE
Now Now() - Returns the current date and time according to the setting of your computer''s system date and time. EXAMPLE
Second Second(time) - Returns a whole number between 0 and 59, inclusive, representing the second of the minute. The time argument is any expression that can represent a time. If time contains Null, Null is returned. EXAMPLE
Time Time() - Returns a Variant of subtype Date indicating the current system time. EXAMPLE
TimeSerial TimeSerial(hour, minute, second)- Returns a Variant of subtype Date containing the time for a specific hour, minute, and second. Arguments:
hour - number between 0 (12:00 A.M.) and 23 (11:00 P.M.), inclusive, or a numeric expression.
minute - any numeric expression.
second - any numeric expression.
EXAMPLE
TimeValue TimeValue(time) - Returns a Variant of subtype Date containing the time.The time argument is usually a string expression representing a time from 0:00:00 (12:00:00 A.M.) to 23:59:59 (11:59:59 P.M.), inclusive. However, time can also be any expression that represents a time in that range. If time contains Null, Null is returned. EXAMPLE
Weekday Weekday(date, [firstdayofweek])- Returns number of day of week:
VbSunday or 1 - Sunday.
VbMonday or 2 - Monday
VbTuesday or 3 - Tuesday.
VbWednesday or 4 - Wednesday.
VbThursday or 5 - Thursday.
VbFriday or 6 - Friday.
VbSaturday or 7 - Saturday
Arguments:
date- any expression that can represent a date. If date contains Null, Null is returned.
firstdayofweek - constant that specifies the first day of the week:
vbUseSystemDayOfWeek or 0 - Use National Language Support (NLS) API setting.
VbSunday or 1 - Sunday (by default).
VbMonday or 2 - Monday.
VbTuesday or 3 - Tuesday.
VbWednesday or 4 - Wednesday.
VbThursday or 5 - Thursday.
VbFriday or 6 - Friday.
VbSaturday or 7 - Saturday.
EXAMPLE
WeekdayName WeekdayName(weekday[, abbreviate[, firstdayofweek]])- Returns a string indicating the specified day of the week. Arguments:
weekday -The numeric designation for the day of the week. Numeric value of each day depends on setting of the firstdayofweek setting.
abbreviate -Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False, which means that the weekday name is not abbreviated.
firstdayofweek - Numeric value indicating the first day of the week:
vbUseSystemDayOfWeek or 0 - Use National Language Support (NLS) API setting.
VbSunday or 1 - Sunday (by default).
VbMonday or 2 - Monday.
VbTuesday or 3 - Tuesday.
VbWednesday or 4 - Wednesday.
VbThursday or 5 - Thursday.
VbFriday or 6 - Friday.
VbSaturday or 7 - Saturday.
EXAMPLE
Year(date)-Returns a whole number representing the year.The date argument is any expression that can represent a date. If date contains Null, Null is returned.
MATHEMATICAL FUNCTIONS:
Atn
Cos
Exp
Log
Randomize
Rnd
Sin
Sqr
Tan
Atn Atn(number) - Returns the arctangent of a number. The number argument can be any valid numeric expression.
Cos Cos(number) - Returns the cosine of an angle. The number argument can be any valid numeric expression that expresses an angle in radians.
Exp Exp(number) - Returns e (the base of natural logarithms) raised to a power. The number argument can be any valid numeric expression.
Log Log(number) - Returns the natural logarithm of argument. The number argument can be any valid numeric expression greater than 0.
Randomize Randomize() -Starts the generator of random numbers.
Rnd Rnd() -Returns a random number in an interval 0-1, if the generator of random numbers previously is started. The number argument can be any valid numeric expression. The value of number determines how Rnd generates a random number:
If "number" is
Rnd generates
Less than zero
The same number every time, using "number" as the seed.
Greater than zero
The next random number in the sequence.
Equal to zero
The most recently generated number.
Not supplied
The next random number in the sequence.
Sin Sin(number) - Returns the sine of an angle. The number argument can be any valid numeric expression that expresses an angle in radians.
Sqr Sqr(number) - Returns the square root of a number. The number argument can be any valid numeric expression greater than or equal to 0.
Tan Tan(number) - Returns the tangent of an angle. The number argument can be any valid numeric expression that expresses an angle in radians.
FUNCTIONS OF OBJECTS:
CreateObject CreateObject(servername.typename [, location]) - Creates and returns a reference to an Automation object. Arguments:
servername - the name of the application providing the object.
typename - the type or class of the object to create.
location - the name of the network server where the object is to be created.
LoadPicture LoadPicture(picturename) Returns a picture object. Available only on 32-bit platforms. LoadPicture(picturename) The picturename argument is a string expression that indicates the name of the picture file to be loaded. More in detail look http://msdn.microsoft.com ...
CODES OF THE ENGINE:
ScriptEngine ScriptEngine() - Returns basic, additional numbers of the version of the engine.
ScriptEngineMajorVersion ScriptEngineMajorVersion() - Returns basic number of the version of the engine.
ScriptEngineMinorVersion ScriptEngineMinorVersion() - Returns additional number of the version of the engine.
ScriptEngineBuildVersion ScriptEngineBuildVersion() - Returns number of the engine.
TEXTUAL FUNCTIONS:
Filter
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
InStr,InStrB
InStrRev
Join
Lcase
Left
LeftB
Len
LenB
LTrim
Mid
MidB
Replace
Right
RightB
Space
Split
StrComp
String
StrReverse
Trim
Unescape
Ucase
Filter Filter(InputStrings, Value[, Include[, Compare]]) - Returns a zero-based array containing a subset of a string array based on a specified filter criteria. Arguments:
InputStrings - one-dimensional array of strings to be searched.
Value - string to search for.
Include - boolean value indicating whether to return substrings that include or exclude Value. If Include is True, Filter returns the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of the array that does not contain Value as a substring.
Compare - numeric value indicating the kind of string comparison to use:
vbBinaryCompare or 0 - Perform a binary comparison.
vbTextCompare or 1 -Perform a textual comparison.
If no matches of Value are found within InputStrings, Filter returns an empty array. An error occurs if InputStrings is Null or is not a one-dimensional array. The array returned by the Filter function contains only enough elements to contain the number of matched items. EXAMPLE - from string "1/2/3/4/5/abc/1" to create array by splitting it on a symbol "/". From the received array to generate other array, by including in it only elements value equal 1, to show result:
FormatCurrency FormatCurrency(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]) - Returns an expression formatted as a currency value using the currency symbol defined in the system control panel. Arguments:
Expression - expression to be formatted.
NumDigitsAfterDecimal - numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit tristate constant that indicates whether or not a leading zero is displayed for fractional values:
TristateTrue or -1 - True
TristateFalse or 0 - False
TristateUseDefault or -2 - Use the setting from the computer's regional settings.'
UseParensForNegativeNumbers - tristate constant that indicates whether or not to place negative values within parentheses.
GroupDigits - tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings.
When one or more optional arguments are omitted, values for omitted arguments are provided by the computer's regional settings. The position of the currency symbol relative to the currency value is determined by the system's regional settings. All settings information comes from the Regional Settings Currency tab, except leading zero, which comes from the Number tab. EXAMPLE - to show number in a money format:
FormatDateTime FormatDateTime(Date[, NamedFormat]) - Returns an expression formatted as a date or time. Arguments:
Date -date expression to be formatted.
NamedFormat - numeric value that indicates the date/time format used:'
vbGeneralDate or 0 - Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.
vbLongDate or 1 - Display a date using the long date format specified in your computer's regional settings.
vbShortDate or 2 - Display a date using the short date format specified in your computer's regional settings.
vbLongTime or 3 - Display a time using the time format specified in your computer's regional settings.
vbShortTime or 4 - Display a time using the 24-hour format (hh:mm).
If omitted, vbGeneralDate is used.
EXAMPLE - to show a string in a format of date:
FormatNumber FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]) - Returns an expression formatted as a number. Arguments:
Expression - expression to be formatted.
NumDigitsAfterDecimal - numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit - tristate constant that indicates whether or not a leading zero is displayed for fractional values:
TristateTrue or -1 - True
TristateFalse or 0 - False
TristateUseDefault or -2 - Use the setting from the computer's regional settings.
UseParensForNegativeNumbers - tristate constant that indicates whether or not to place negative values within parentheses:
TristateTrue or -1 - True
TristateFalse or 0 - False
TristateUseDefault or -2 - Use the setting from the computer's regional settings.
GroupDigits - tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the control panel:
TristateTrue or -1 - True
TristateFalse or 0 - False
TristateUseDefault or -2 - Use the setting from the computer's regional settings.
When one or more of the optional arguments are omitted, the values for omitted arguments are provided by the computer's regional settings. All settings information comes from the Regional Settings Number tab. EXAMPLE - to show a string in a format of number:
FormatPercent FormatPercent(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]) - Returns an expression formatted as a percentage (multiplied by 100) with a trailing % character. Arguments:
Expression - expression to be formatted.
NumDigitsAfterDecimal - numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit - tristate constant that indicates whether or not a leading zero is displayed for fractional values.
UseParensForNegativeNumbers - tristate constant that indicates whether or not to place negative values within parentheses.
GroupDigits - tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the control panel.
The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings:
TristateTrue or -1 - True
TristateFalse or 0 - False
TristateUseDefault' or -2 - Use the setting from the computer's regional settings.
When one or more optional arguments are omitted, the values for the omitted arguments are provided by the computer's regional settings. All settings information comes from the Regional Settings Number tab. EXAMPLE - to show number in a format of percents:
InStr,InStrB InStr([start, ]string1, string2[, compare]) - Returns the position of the first occurrence of one string within another. InStrB([start, ]string1, string2[, compare]) - Returns the byte position of the first occurrence of one string within another. All possible values of return look the table below.
Returned value depending on a condition
If
InStrRev returns
"string1" is zero-length
0
"string1" is Null
Null
"string2" is zero-length
start
"string2" is Null
Null
"string2" is not found
0
"string2" is found within "string1"
Position at which match is found
"start" >Len("string2")
0
Arguments:
start - numeric expression that sets the starting position for each search. If omitted, search begins at the first character(byte) position. If start contains Null, an error occurs. The start argument is required if compare is specified.
string1 - string expression being searched.
string2 - string expression searched for.
compare - numeric value indicating the kind of comparison to use when evaluating substrings.If omitted, a binary comparison is performed. For the set of a kind of comparison look the table below.
Constant
Value
Description
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform a textual comparison.
EXAMPLE - to find a position "5" in a string "1234567890":
EXAMPLE - to find a position of byte "5" in a line "1234567890":
InStrRev InStrRev(string1, string2[, start[, compare]]) - Returns the position of an occurrence of one string within another and other values, from the end of string. All possible values of return look the table below.
Returned value depending on a condition
If
InStrRev returns
"string1" is zero-length
0
"string1" is Null
Null
"string2" is zero-length
start
"string2" is Null
Null
"string2" is not found
0
"string2" is found within "string1"
Position at which match is found
start >Len("string2")
0
Arguments:
string1 - string expression being searched.
string2 - string expression being searched for.
start - numeric expression that sets the starting position for each search. If omitted, -1 is used, which means that the search begins at the last character position. If start contains Null, an error occurs.
compare - numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary comparison is performed. For the set of a kind of comparison look the table below.
Constant
Value
Description
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform a textual comparison.
EXAMPLE - to find value of a position "9" in a string "0987654321" and to show result:
Join Join(list[, delimiter]) - Returns a string created by joining a number of substrings contained in an array. Arguments:
list - one-dimensional array containing substrings to be joined.
delimiter - string character used to separate the substrings in the returned string. If omitted, the space character (" ") is used. If delimiter is a zero-length string, all items in the list are concatenated with no delimiters.
EXAMPLE - to split a string "1/2/3/4/5" on a symbol "/" to join the received array, and to show result:
Lcase Lcase(string) - Transforms all symbols of a string to lower case symbols. The string argument is any valid string expression. If string contains Null, Null is returned. EXAMPLE - to transform upper case symbols of a line "HELLO"! In lower case and to show result:
Left Left(string, length) - Returns a specified number of characters from the left side of a string. Arguments:
string - string expression from which the leftmost characters are returned. If string contains Null, Null is returned.
length - numeric expression indicating how many characters to return. If 0, a zero-length string("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.
EXAMPLE - to receive from a string "abcde" a string from first three symbols and to show result:
LeftB LeftB(string,length) - Returns a specified number of bytes from the left side of a string. Arguments:
string - string expression from which the leftmost bytes are returned. If string contains Null, Null is returned.
length - numeric expression indicating how many bytes to return. If 0, a zero-length string("") is returned. If greater than or equal to the number of bytes in string, the entire string is returned.
EXAMPLE - to transform number 12345678 to 16 system of calculation to show first four bytes and to show number in 16 systems:
Len Len(string | varname) - Returns the number of characters in a string or the number of characters required to store a variable. Arguments:
string Any valid string expression. If string contains Null, Null is returned.
varname Any valid variable name. If varname contains Null, Null is returned.
EXAMPLE - to show number of symbols of a string "abcde":
LenB LenB(string | varname) - Returns the number of bytes in a string or the number of bytes required to store a variable. Arguments:
string Any valid string expression. If string contains Null, Null is returned.
varname Any valid variable name. If varname contains Null, Null is returned.
EXAMPLE - to show number of bytes of a string "abcde":
LTrim LTrim(string) - Returns a string without leading spaces (LTrim),. The string argument is any valid string expression. If string contains Null, Null is returned. EXAMPLE - to remove initial apaces of a line "abcde" and to show result:
Mid Mid(string, start[, length]) - Returns a specified number of characters from a string. Arguments:
string - string expression from which characters are returned. If string contains Null, Null is returned.
start - character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ("").
length - number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.
EXAMPLE - from a string "abcde" to take two symbols since third and to show result:
MidB MidB(bytes, beginning, quantity) - Returns a specified number of bytes from a string. Arguments:
string - string expression from which bytes are returned. If string contains Null, Null is returned.
start - byte position in string at which the part to be taken begins. If start is greater than the number of bytes in string, Mid returns a zero-length string ("").
length - number of bytess to return. If omitted or if there are fewer than length bytes in the text (including the byte at start), all bytes from the start position to the end of the string are returned.
EXAMPLE - from a string "abcde" to take four bytes since third and to show result:
Replace Replace(expression, find, replacewith[, start[, count[, compare]]]) - Returns a string in which a specified substring has been replaced with another substring a specified number of times. All values which can be returned, depending on a condition:
If
Replace returns
"expression" is zero-length
Zero-length string ("").
"expression" is Null
An error.
"find" is zero-length
Copy of "expression".
"replacewith" is zero-length
Copy of "expression" with all occurrences of "find" removed.
"start" > Len("expression")
Zero-length string.
"count" is 0
Copy of "expression".
Arguments:
expression - string expression containing substring to replace.
find - substring being searched for.
replacewith - replacement substring.
start - position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count.
count - number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start.
compare - numeric value indicating the kind of comparison to use when evaluating substrings:
vbBinaryCompare or 0 - Perform a binary comparison.
vbTextCompare or 1 - Perform a textual comparison.
The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and concludes at the end of the expression string. It is not a copy of the original string from start to finish. EXAMPLE - in a string "a/b/c/d/e" a symbol "/" to replace with a symbol "*" and to show result:
Right Right(string, length) - Returns a specified number of characters from the right side of a string. Arguments:
string - string expression from which the rightmost characters are returned. If string contains Null, Null is returned.
length - numeric expression indicating how many characters to return. If 0, a zero-length string is returned. If greater than or equal to the number of characters in string, the entire string is returned.
EXAMPLE - to receive from a string "abcde" a substring from last three symbols and to show result:
RightB RightB(string, length) - Returns a specified number of bytes from the right side of a string. Arguments:
string - string expression from which the rightmost bytes are returned. If string contains Null, Null is returned.
length - numeric expression indicating how many bytes to return. If 0, a zero-length string is returned. If greater than or equal to the number of bytes in string, the entire string is returned.
EXAMPLE - to transform number 12345678 to 16 system of calculation to show last four bytes and to show number in 16 systems:
RTrim RTrim(string) - Returns a string without trailing spaces. The string argument is any valid string expression. If string contains Null, Null is returned. EXAMPLE - to remove from a string "abcde" final spacess and to show result:
Space Space(number) - Returns a string consisting of the specified number of spaces. The number argument is the number of spaces you want in the string. EXAMPLE - in a string "abcde" after the first symbol to add three spaces and to show result:
Split Split(expression[, delimiter[, count[, compare]]]) - Returns a zero-based, one-dimensional array containing a specified number of substrings. Arguments:
expression - string expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.
delimiter - string character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count - number of substrings to be returned; -1 indicates that all substrings are returned.
compare - numeric value indicating the kind of comparison to use when evaluating substrings:
vbBinaryCompare or 0 - Perform a binary comparison.
vbTextCompare or 1 - Perform a textual comparison.
EXAMPLE - to split a string "1/2/3/4/5" on a symbol "/" , to join the received array, and to show result:
StrComp StrComp(string1, string2[, compare]) - Returns a value indicating the result of a string comparison.
The table of returned value depending on a condition
Value
Condition
0
if the string1 is equalled a string2
-1
if the string1 is less than string2
1
if the string1 is more than string2
Null
if the string1 or string2 has value Null
Arguments:
string1 - any valid string expression.
string2 - any valid string expression.
compare - numeric value indicating the kind of comparison to use when evaluating strings. If omitted, a binary comparison is performed:
vbBinaryCompare or 0 - Perform a binary comparison.
vbTextCompare or 1 - Perform a textual comparison.
EXAMPLE - to compare identical strings and to show result of comparison:
String String(number, character) - Returns a repeating character string of the length specified. Arguments:
number - length of the returned string. If number contains Null, Null is returned.
character - character code specifying the character or string expression whose first character is used to build the return string. If character contains Null, Null is returned.
If you specify a number for character greater than 255, String converts the number to a valid character code using Mod 256. EXAMPLE - to show a string from 10 symbols "*":
StrReverse StrReverse(string) - Returns a string in which the character order of a specified string is reversed. The string argument is the string whose characters are to be reversed. If string is a zero-length string (""), a zero-length string is returned. If string is Null, an error occurs. EXAMPLE - to show a string with changed on the opposite order of symbols "12345":
Trim Trim(string) - Returns a string without both leading and trailing spaces. The string argument is any valid string expression. If string contains Null, Null is returned. EXAMPLE - at a string of symbols " 12345 " to remove initial and final apaces and to show result:
Unescape Unescape(charString) - Decodes a string encoded with the Escape function. The Unescape function returns a string (in Unicode format) that contains the contents of charString. ASCII character set equivalents replace all characters encoded with the %xx hexadecimal form. Characters encoded in %uxxxx format (Unicode characters) are replaced with the Unicode character with hexadecimal encoding xxxx.
Ucase Ucase(string) - All symbols in a string replaces lower case symbols. If string contains Null, Null is returned. EXAMPLE - to transform lower case symbols of a line "hello!" in upper case symbols, and to show result:
FUNCTIONS OF CHECK VARIABLES:
IsArray
IsDate
IsEmpty
IsNull
IsNumeric
IsObject
IsArray IsArray(name_of_variable) - Returns True, if variable, which name is specified in parameter, there is array, and False otherwise.
IsDate IsDate(expression) - Returns True, if expression, which is specified in parameter, has a type of date and False otherwise.
IsEmpty IsEmpty(expression) - Returns False, if expression, which is specified in parameter, has received value, and True otherwise.
IsNull IsNull(expression) - Returns True, if expression, which is specified in parameter, has incorrect value, and False otherwise.
IsNumeric IsNumeric(expression) - Returns True, if expression, which is specified in parameter, has a type of number, and False otherwise.
IsObject IsObject(expression) - Returns True, if expression which is specified in parameter, has a type of object, and False otherwise.
VarType VarType(name_of_variable) - Returns a subtype variable as number. For viewing numbers click: Constants of a subtype variable
Definition of variables
Dim dev1,dev2,dev3-defines obviously variables.
Processing of errors EXAMPLE - to create a error by extraction of a root square of a negative number and to give out a code of a error:
The comment for example: line_1-to ignore error line_2-creation of error line_3-analysis a code of error and if error there is line_4-display of its code.
INPUT~OUTPUT:
msgbox
inputbox
msgbox Gives out the message and can return value, depending on that, what button was pressed(clicked).
Value, returned by the function MSGBOX, with pressing the buttons.
button
constant
value
OK
vbOK
1
Cancel
vbCancel
2
Abort
vbAbort
3
Retry
vbRetry
4
Ignore
vbIgnore
5
Yes
vbYes
6
No
vbNo
7
inputbox Enter the data and press the necessary button.
Heading........
Instruction.....
By default......
For a place of a window of input on centre the following items to not enter.
X windows of input...
Y windows of input...
Comment The text of the comment in VBS is the text beginning with symbols: ' or rem. NOTE: the comments in the scripts, which in tag are forbidden.
Explicit definition variable Option Explicit For avoidance of errors with application variable it is recommended in the beginning of the script to enter this operand. Thus all variable before their application should be defined by an operand DIM.