Work with the Array.
| Syntax | Example | Description |
|---|---|---|
| Dim name_of_array. | dim a(10),b(20,30) | declarate array |
| Array (value1,value2,...valueN) | Dim myArray myArray=Array(10,20,30) |
Assign values to array. |
| Erase ARRAY | erase a | Erase array values. |
| ReDim name_of_array or name_of_array(indexs) | ReDim a(10) | Declarate or change lenght of array. (also see Preserve) |
| Preserve name_of_array(indexs) | ReDim Preserve a(10) | Change lenght of array without lost data. (also see ReDim) |
Functions for work with the array.
| Syntax | Example | Description |
|---|---|---|
| IsArray(name_of_array) | If IsArray(a) Then ... | True - a is array; False - a is not array |
| LBound (name_of_array) | n=LBound(a) | in VBScript always return 0 |
| UBound (name_of_array) | n=UBound(a) | Return maximum value of array. |
| Split (value[,delimit[,count[,method]]]) | Split("a,b",",") | Return array by delimitor. Method - vbBinaryCompare or vbTextCompare. |
| Join (array[,delimit]) | s=Join(a,",") | Join elements of array to string. |
| Filter (array,filer[,key[,compare method]]) | s=Filter(a,"assa",blInclude) | return array from given array by filter. |
Assign operations.
| Syntax | Example | Description |
|---|---|---|
| variable = value | a=137 a=b c="hallo" | set value to variable. |
| Set variable = object | Set a=object | Set object referance to array. |
Comments.
| Syntax | Example | Description |
|---|---|---|
| ' comments | ' text | |
| Rem comments | rem text |
Constants and literal.
| Syntax | Example | Description |
|---|---|---|
| variable = False | if a=false then ... | variable type boolean = 0 |
| variable = True | if a=true then ... | variable type boolean = -1 |
| Empty | x=Empty | Automaticaly assign in each variable when it declarate. |
| Null | If x=Null Then ... | |
| Nothing | Set variable =Nothing |
Functions.
| Syntax | Example | Description |
|---|---|---|
| Abs (number) | a=Abs(-1.34) ... a=1.34 | Absalute value of number. |
| Asc (number) | a = Asc("s") ... a=115 | ANSI symbol code |
| CBool (expresion) | If CBool(x)=True Then ... | Return boolean type for correct expresion. |
| CByte (expresion) | x=CByte(x) | Return Byte type for correct expresion. |
| CCur (expresion) | CCur(x) | Special number format for currency. |
| CDate (expresion) | x=CDate(x) | Return Date for correct expresion. |
| CDbl (expresion) | x=CDbl(x) | Return Double type for correct expresion. |
| Chr (number) | a = Chr(115) ... a="s" | Return symbol by symbol code. |
| CInt (expresion) | a = CInt(x) | Return Integer value. |
| CLng (expresion) | a = CLng(x) | Return Long value. |
| CSng (expresion) | a = CSng(x) | Return Single value. |
| CStr (expresion) | a = CStr(x) | Return String value. |
| Date () | curDate = Date() | Return current Date. |
| DateAdd (interval,number,data) | dDate = DateAdd(vDateOption,10,Now()) | Returns a Date value containing a date and time value to which a specified time interval has been added. |
| DateDiff (interval,data1,data2[,first day of week[,first day of year]]) | dDate = DateDiff("d",10/10/98,10,10/97) | Returns a Long value specifying the number of time intervals between two Date values. |
| DatePart (interval,data[,first day of week[,first day of year]]) | dDate = DatePart(vDateOption,10/10/98 ,vDOWOption,vWOYOption) |
Returns an Integer value containing the specified component of a given Date value. |
| DateSerial (year,month,day) | newDate = DateSerial(2001,4,30) | Return Date type value. |
| DateValue (expresion) | myDate = DateValue(x) | Return Data value for any expresion which is correct date. |
| Day () | curDay = Day() | Return integer(1-31) value day of months. |
| FormatCurrency FormatDateTime FormatNumber FormatPercent |
- | Format data |
| Hex (number) | a = hex(543) ... a="21F" | Hex(16) presentation. |
| Hour (expresion), Minute (expresion), Month (expresion), Second (expresion), Year (expresion), Weekday (expresion) |
a = hour(now) ... | Hour Minut Month Second Year Week day (sanday=1) |
| Int (number) | a = int(-1.5) ... a=-2 | integer value, round. |
| MonthName () | n = MonthName() | Return month name. (1-12) |
| Now () | a = Now() | Current system Date and time |
| Oct (number) | a = oct(543) ... a="1037" | Oct presentation. |
| Round (expresion[,кол-во дробных десятичных знаков]) | n=Round(10.125,2) | rounds up a number to a certain number of decimal places. |
| Sgn (number) | a = sgn(-1.3) ... | Number symbol. |
| Time() | a = Time() | Current sysytem time |
| Timer() | a = Timer() | Second count. |
| TimeSerial (hour, minut, second) | a = TimeSerial(10,15,00) | return Date type. |
| TimeValue (expresion) | a = TimeValue(x) | return Date type for datatime. |
Math functions.
| Syntax | Example | Description |
|---|---|---|
| Atn (number) | a = Atn(0.37) | Returns a Double value containing the angle whose tangent is the specified number. |
| Cos (number) | a = Cos(0.37) | Returns a Double value containing the cosine of the specified angle. |
| Exp (number) | a = Exp(0.37) | Returns a Double value containing e (the base of natural logarithms) raised to the specified power. |
| Log (number) | a = Log(0.37) | Returns a Double value containing the logarithm of a specified number. This method is overloaded and can return either the natural (base e) logarithm of a specified number or the logarithm of a specified number in a specified base. |
| Randomize() | Randomize() | Initializes the random-number generator. |
| Rnd (number) | a = Rnd(1) | Rundom number 0..1 |
| Sin (number) | a = Sin(0.37) | Returns a Double value specifying the sine of an angle. |
| Sqr (number) | a = Sqr(0.37) | Returns a Double value specifying the square root of a number. |
| Tan (count) | a = Tan(0.37) | Returns a Double value containing the tangent of an angle. |
Functions which returnted subtype of data.
| IsArray (expression), IsDate (expression), IsEmpty (expression), IsNull (expression), IsNumeric (expression), ValType (expression) |
String functions.
| Syntax | Example | Description |
|---|---|---|
| InStr (start, string, searching substring) | If InStr(1,mail,@) then ... | Return the symbol number from the string which position start substring. |
| LCase (string) | a=LCase("SoftWare DevelopEr") ... a="software developer" | Set string to lowercase |
| UCase (string) | a=UCase("SoftWare DevelopEr") ... a="SOFTWARE DEVELOPER" | Set string to uppercase |
| Left (string,N symbol) | a=Left("Software developer",8) ... a="Software" | Left part of the string with the N symbol lenght. |
| Right (string,N symbol) | a=Right("Software developer",9) ... a="developer" | Right part of the string with the N symbol lenght. |
| Len (string) | a=Len("Software developer") ... a=18 | String lenght. |
| LTrim (string) | a=LTrim(" Software developer ",) a="Software developer " | Remove spaces of string from start. |
| RTrim (string) | a=RTrim(" Software developer ",) a=" Software developer" | Remove spaces of string from end. |
| Trim (string) | a=Ttrim(" Software developer ",) a="Software developer" | Remove spaces of string from start and end. |
| Mid (string, start, N symbol) | a=Mid("Software developer",10,9) a="developer" | Return part of string with the "start" position and N symbol. |
| StrComp (string1, string2[, comparation method]) | If StrComp("Software","developer")=1 Then ... | Return result of 2 string comparation(Integer): -1 string1 1 string1>string2. |
| Space(N) | a=Space(5) | String with the N space |
| String (N symbol, symbol) | a=String(5,"A") a="AAAAA" | String line with the N symbol. |
| Replace (string,substring being searched for,Replacement substring[,start[,count[, comparation method]]]) | s=Replace("Software developer","developer","development") a="Software development" | Returns a string in which a specified substring has been replaced with another substring. |
| InStrRev (string,substring,[,start[,comparation method]]) | n=InStrRev("Software developer","f") | returns the position of the first occurrence of one string within another. |
| StrReverse (string) | s=StrReverse("hallo") | return a string in reverse |
Repeatedly executed and conditions
| Call event_name | Call but_onclick | Call subprogramm |
| Do ... Loop Until condition |
Do a=a+1 Loop Until a>=5 |
Run code while condition is not true (run at last one time) |
| Do ... Loop While condition |
Do a=a+1 Loop While a<5 |
Run code while condition true (run at last one time). |
| Do Until condition ... Loop |
Do Until a>=5 a=a+1 Loop |
Repeat code until condition is became true. |
| Do While condition ... Loop |
Do While a<5 a=a+1 Loop |
Repeat code while condition is true. |
| For variable=strart To end Step step ... next |
For i=1 to 5 a=a+1 next |
(note: next not next i) |
| IF condition Then action1 Else action2 End if |
IF a < 1 Then alert">" | Make operations if condition true. |
| Select Case X Case value1 action Case value2 action2 ... End select |
Select Case X Case 10 alert"x=10" Case 20 alert"x=20" End select |
Runs one of several groups of statements, depending on the value of an expression. |
| While condition action Wend |
While a<5 a=a+1 Wend |
Do operation while conditions is true. |
Operators which used in expresions.
| + And / = Eqv ^ > <= Imp <> \ < => Mod * - Or & Xor |
Declarate functions and procedures.
| Dim variable | Dim a | Declare variable. |
| Sub event_name code End sub |
Sub but_onclick Alert x End sub |
Subprograms |
| Function name(parameters) code End function |
Function(x,y) x=x*y End function |
Function |
| Exit ... | Exit Do (For, Function, Sub) |
Work with the errors.
| Syntax | Example | Description |
|---|---|---|
| Clear | Err.Clear | set Err.Number to 0. |
| Description | Err.Description | Last error description. |
| Err | Err.property!method | Object witch contain last error information. |
| On Error | On Error Resume Next | When error appeared go to next line. Ignore error. |
| Raise | Err.Raise(error number) | Raise error. |
| Number | Err.Number | Error number. |
| Source | Err.Source | Object name where appeared a error. |
Subtype VARIANT.
| Syntax | Example | Description |
|---|---|---|
| Empty | - | Assign automatically to data when it defining. |
| Null | - | |
| Boolean | CBool(x) | This data have 2 value True and False. |
| Byte | CByte(x) | The most small data type from 0 to 255 |
| Integer | CInt(x) | Data type from -32768 to 32768. |
| Long | CLng(x) | Long data type from -2147483648 to 2147483647 |
| Single | CSngl(x) | Number type and float point (2). |
| Double | CDbl(x) | Number type and float point (2). |
| Date/Time | CDate(x) | show date from 1 Jun 100 year to 31 Dec 9999 year |
| Currency | CCur(x) | Special number format for currency. |
| String | CStr(x) | Symbol data type. |
| Object | - | Link to objects ole, html, ActiveX |
| Error | - | Data type for storing error number. |
Constant for subtype define.
| vbBoolean - 11, vbByte - 17, vbCurrency - 6, vbDataObject - 13, vbDate - 7, vbDecimal - 14, vbDouble - 5, vbEmpty - 0, vbError - 10, vbInteger - 2, vbLong - 3, vbNull - 1, vbObject -9, vbSingle - 4, vbString - 8, vbVariant - 12, vbArray - 8192 |
Constatnts for special symbol.
| Syntax | Example | Description |
|---|---|---|
| vbCr | Chr(13) | Short enter. |
| vbCrLf | Chr(13) + Chr(10) | Short enter and bracke line. |
| vbLf | Chr(10) | Brack line. |
| vbNewLine | Chr(13) and Chr(10) or Chr(10) |
New line(depend on Operation System). |
| vbNullChar | Chr(0) | String with the 0 code. Equal NULL (in C language). |
| vbNullString | String with the 0 code. | Empty string. Equal NULL (in C language). |
| vbTab | Chr(9) | Vertical tab. |
home
Info
sitemap



