Altium NEXUS Documentation

VBScript Statements Supported in Altium NEXUS

Created: January 9, 2020 | Updated: July 21, 2021

Parent page: VBScript

Conditional Statements

The main conditional statements supported by VBScript are:

  • If...Then
  • For Next Loop
  • Exit For
  • For Each Next
  • Do Loop
  • While...WEnd
  • Select Case

Care needs to be taken to code scripts that avoid infinite loops — that is, ensuring that the conditions will eventually be met.

The If...Then Statement

The syntax is:

If Condition Then
Else If AnotherCondition Then
End If

The For Loop

The For Next statement repeatedly loops through a block of code. The basic syntax is:

For counter = start to end
  ' block of code here

The Exit For

The Exit For statement exits a For loop prematurely.

For counter = start to end
  if condition then Exit For

The For Each Loop

The For Each loop is a variation on the For loop which is designed to iterate through a collection of objects as well as elements in an array. The basic syntax is:

For Each ObjectVar in Collection
  ' block of code here

The Do Loop

The Do Loop has several loop variations.

Do while until condition
  ' code block


  ' code block
Loop while until condition


  ' code block

The While...WEnd Loop

The While WEnd statement repeatedly loops through a block of code. The basic syntax is:

While until condition
  ' code block

The Select Case Statement

You can use the SELECT statement if you want to select one of many blocks of code to execute:

Select case payment
  case "Cash"
    msgbox "pay cash"
  case "MasterCard"
    msgbox "pay by Mastercard"
  case Else
    msgbox "Unknown payment method"
end select

Expressions and Operators

An expression is a valid combination of constants, variables, literal values, operators, and function results. Expressions are used to determine the value to assign to a variable, to compute the parameter of a function, or to test for a condition. Expressions can include function calls.

VBScript has a number of logical, arithmetic, Boolean and relational operators. Since these operators are grouped by the order of precedence which is different from the precedence orders used by Basic, C, etc. For example, the AND and OR operators have precedence compared to the relational one.

Arithmetic Operators










Division with an integer result





Comparison Operators (Lowest Precedence)


Test whether equal or not.


Test whether not equal or not.


Test whether less than or not.


Test whether greater than or not.


Test whether less than or equal to or not.


Test whether greater than or equal to or not.


Compares two object reference variables.

String Operators



Logical Operators


Logical NOT


Logical AND


Logical OR









Found an issue with this document? Highlight the area, then use Ctrl+Enter to report it.

Contact Us

Contact our corporate or local offices directly.

We're sorry to hear the article wasn't helpful to you.
Could you take a moment to tell us why?
200 characters remaining
You are reporting an issue with the following selected text
and/or image within the active document: