![LeCroy WaveRunner 104MXI Скачать руководство пользователя страница 198](http://html1.mh-extra.com/html/lecroy/waverunner-104mxi/waverunner-104mxi_operators-manual_1866369198.webp)
W
AVE
R
UNNER
X
I
S
ERIES
198
WRXi-OM-E Rev B
Example file for these constructions: DoLoops.Xls
While . . . Wend
This is similar to Do While . . . Loop. You can write things like:
While ( (A > 2) And (C < 92677663) )
AnyVBCalculation
Wend
For . . . Next
Sometimes you know, or you think you know, the number of times that you want to do a job. For this case a For
loop is ideal, especially when you have an array of numbers to work with.
Examples:
For K = 0 To Total
HistogramBin (K) = 0
Next
Omega = TwoPi / Period
For N = 0 To Period
Y (N) = A * Sin (Omega * N)
Next
Be careful about changing the counting variable in any loop. You can do this to terminate the loop early (but
Exit
For
is better), but you could also prevent it from terminating at all.
For emergency exit, you can use
Exit For
. For example:
For K = 0 To Total
If HistogramBin(K) = 0 Then Exit For
AnyVBScripting
Next
It is possible to make a For loop with steps greater than 1, as in the following example in which K takes the values
3, 7, 11, 15, . . . . 83.
For K = 3 To 82 Step 4
AnyVBScripting
Next K
You may place loops inside one another (nested loops), but they must all use different control variables. Example:
For K = 0 To N
VBScriptingK
For L = - 7 To 17
VBScriptingL
For M = S To T
VBScriptingM
Next
Next