Code:

OPTION strict
dim first as N 'Starting number
dim last as N 'Ending number
dim total as N 'For final total
dim count as N 'To count the number of times this code is run, but it won't be that important as you will see.
count = 0 'Starting counter at 0
first = 102 'Starting point
last = 302 'Ending point
total = ( ( first + last ) * ( last - first ) ) / 4
'By adding in the first and last numbers I am figuring out a standard number for the math
'and by subtracting the last and first from eachother, I am counting the total of the
'numbers between the first and last. Since I am adding in both first and last numbers,
'I only need to figure in half of those numbers, and since only even numbers are counted,
'I need only half of those numbers still. So I divide the total by 4.
'logically it should have divided the (last-first) before being multiplied, but the result is the same.
count = count + 1 'Adding to the counter
'Results:
ui_msg_box( " Total" , total ,UI_ATTENTION_SYMBOL )
'Number of times the formula had to be run:
ui_msg_box( "Times Run" , count , UI_ATTENTION_SYMBOL )

Admittedly I am cheating here by not using a loop.

## Bookmarks