Difference between revisions of "VBScript reference"
m (1 revision imported) |
|
(No difference)
|
Latest revision as of 08:20, 1 December 2017
This is a quick reference for the language for keywords and built-in methods [1].
Contents
Methods
Here are all available built-in VBScript functions:
- Date and time methods
- CDate(Value)
- Date()
- DateAdd(Interval, Number, Date)
- DateDiff(Interval, Date1, Date2, optional FirstDayOfWeek, optional FirstWeekOfYear)
- DatePart(Interval, Date, optional FirstDayOfWeek, optional FirstWeekOfYear)
- DateSerial(Year, Month, Day)
- DateValue(Date)
- Day(Date)
- FormatDateTime(Date, Format)
- Hour(Time)
- IsDate(Date)
- Minute(Time)
- Month(Date)
- MonthName(Month, optional Abbreviate)
- Now()
- Second(Time)
- Time()
- Timer()
- TimeSerial(Hour, Minute, Second)
- TimeValue(Time)
- Weekday(Date, optional FirstDayOfWeek)
- IsDate(Weekday, optional Abbreviate, optional FirstDayOfWeek)
- Year(Date)
- Format methods
- FormatCurrency(Number, optional DigitsAfterDecimal, optional IncludeLeadingZero, optional UseParenthesesForNegative, optional GroupDigits)
- FormatDateTime(Date, Format)
- FormatNumber(Number, optional DigitsAfterDecimal, optional IncludeLeadingZero, optional UseParenthesesForNegative, optional GroupDigits)includeleadingzero, optional useparenthesesfornegative, optional groupdigits)
- FormatPercent(Number, optional DigitsAfterDecimal, optional IncludeLeadingZero, optional UseParenthesesForNegative, optional GroupDigits)
- String methods
- InStr(optional Start, String1, String2, optional CompareMode)
- InStrRev(String1, String2, optional Start, optional CompareMode)
- LCase(Str)
- Left(Str, Length)
- Len(Str)
- LTrim(Str)
- Mid(Str, Start, optional Length)
- Replace(Str, Find, ReplaceWith, optional Start, optional Count, optional CompareMode)
- Right(Str, Length)
- RTrim(Str)
- Space(Number)
- StrComp(Str1, Str2, optional CompareMode)
- String(Number, Character)
- StrReverse(Str)
- Trim(Str)
- UCase(Str)
- Other methods
- CreateObject("Project.Object", optional Location)
- GetObject(optional Path, optional Class)
- GetRef(FunctionName)
- Eval(Expression)
- Execute Expression
- ExecuteGlobal Expression
- ScriptEngine()
- ScriptEngineMajorVersion()
- ScriptEngineMinorVersion()
- ScriptEngineBuildVersion()
- LoadPicture(Path)
- RGB(Red, Green, Blue)
- InputBox(Text, optional Title, optional Default, optional XPos, optional YPos, optional Helpfile, optional Context)
- MsgBox(Text, optional Flags, optional Title, optional Helpfile, optional Context)
- GetLocale()
- SetLocale(Lcid)
Objects
- Common ActiveX objects available via the CreateObject() function
- Scripting.Dictionary
- Scripting.FileSystemObject
- WScript.Shell
- WScript.Network
- MSComDlg.CommonDialog
- TLI.TLIApplication
- InetCtls.Inet (this can now be done with the CreateObj function instead)
- MSWinsock.Winsock (events won't be available; this can now be done with the CreateObj function instead)
- Sapi.SpVoice (this may not be available on all computers)
- Built-in objects
Constants
Template:Main Here are all the categories of VBScript constants:
- Color constants
- Compare mode settings
- Date format settings
- First day of week settings
- First week of year settings
- Message box results
- Message box settings
- String constants
- Variable types
- Other constant values
Keywords
Here is a list of all available VBScript keywords in alphabetical order and a link to the article about them.
And
- Logical or bitwise conjunctionByVal
- By valueByRef
- By referenceCall
- Calling subroutines and functionsCase
-Select Case
block andCase
blockClass
- Class blockConst
- Declaring constantsDefault
- Default memberDim
- Declaring variablesDo
-Do
loopEach
-For Each
blockElse
-Else
statementElseIf
-ElseIf
...Then
statementEmpty
- An uninitialized valueEnd
- End anIf
,Select
,Sub
,Function
,Property
,Class
, orWith
blockEqv
- Logical or bitwise equivalenceError
-On Error Resume Next
statement orOn Error GoTo 0
statementExit
- Exit aFor
,Do
,Sub
,Function
, orProperty
blockExplicit
-Option Explicit
statementFalse
- A negative BooleanFor
-For
loopFunction
-Function
blockGet
-Property Get
blockGoTo
-On Error GoTo 0
statementIf
-If
...Then
statement or blockImp
- Logical or bitwise implicationIn
-For Each
blockIs
-Is
operatorLet
-Property Let
blockLoop
- End ofDo
loopMod
- ModulusNew
- Creating custom objectsNext
- End ofFor
loop orOn Error Resume Next
statementNot
- Logical or bitwise negationNothing
- Cleaning up withNothing
Null
- A value with no dataOn
-On Error Resume Next
statement orOn Error GoTo 0
statementOption
-Option Explicit
statementOr
- Logical or bitwise disjunctionReDim
- Dynamic arraysRem
- CommentsResume
-On Error Resume Next
statementPreserve
- Dynamic arraysPrivate
- Declaring private variables or declaring private methodsProperty
-Property
blocksPublic
- Declaring public variables or declaring public methodsSelect
-Select Case
blockSet
-Property Set
block or Object assignmentStep
-For
blockSub
-Sub
blockThen
-If
...Then
statement or block orElseIf
...Then
statementTo
-For
blockTrue
- A positive BooleanUntil
-Do
loopWend
- End aWhile
loopWhile
-While
loop orDo
loopWith
-With
blockXor
- Logical or bitwise exclusion- Object
.
Member operator - Accessing object members +
- Addition, string concatenation, or unary plus'
- Comments/
- Division (decimal)\
- Division (integer)=
- Equals comparison^
- Exponent>
- Greater than comparison>=
- Greater than or equal to comparison<
- Less than comparison<=
- Less than or equal to comparison:
- Line combination_
- Line split*
- Multiplication<>
- Not equal comparison(
...)
- Parentheses[
...]
- Square bracketed identifiers&
- String concatenation-
- Subtraction or unary negation