Agilent Technologies E5071C Manual page 1101

Hide thumbs Also See for E5071C:
Table of Contents

Advertisement

E5071C
This section walks through a sample program that finds the maximum
value contained in an array while breaking down the code into a number of
blocks and describing what they do. Line numbers are added for
description purpose only, and do not appear in the actual program source
code.
Sample program that finds the maximum value contained in an
array
10| Option Explicit
20|
30| Sub Maximum()
40|
50| Dim q As Variant
60| Dim x(100) As Integer
70| Dim i As Integer, n As Integer
80| Dim Start As Integer, Last As Integer, Num As Integer
90| Dim Maximum As Integer
100|
110| ' Defining the array
120| q = Array(7, -2, 3, -20, 15, -6, 27, -12, 9, -5, 18, 23, _
130| 9, -16, 22, 0)
140|
150| Start = LBound(q)
160| Last = UBound(q)
170| Num = Last - Start + 1
180|
190| For i = Start To Last
200| x(i) = q(i)
210| Next i
220|
230| Maximum = x(Start)
240|
250| For n = Start + 1 To Last
260| If x(n) > Maximum Then Maximum = x(n)
270| Next n
280|
290| MsgBox Maximum
300|
310| End Sub
1328

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents