SUBROUTINE HELP

B

biker man

I am trying to write a subroutine where A is the array of temperature
data

lenght is the number of temperature records to be searched

and MIN and Max to return the values

i want to rite a sub routine to returnt he largest and smallest value
of an array of an given length

ive starting with a calling line which is

CALL BigLittle(A,Length,Max,Min)

any help would be greAT













what do pass by adress and pass by value mean??
 
D

Dave Peterson

With no validation...

Option Explicit
Sub testme()

Dim myBigArray() As Double
Dim myMaximum As Double
Dim myMinimum As Double
Dim myLength As Long
Dim iCtr As Long

ReDim myBigArray(5 To 35)
For iCtr = LBound(myBigArray) To UBound(myBigArray)
'some testdate
myBigArray(iCtr) = iCtr / 100
Next iCtr

myLength = 5

Call BigLittle(myBigArray, myLength, myMaximum, myMinimum)

MsgBox myMaximum & vbLf & myMinimum

End Sub

Sub BigLittle(myArr() As Double, myLen As Long, _
myMax As Double, myMin As Double)

Dim myLittleArr() As Double
Dim iCtr As Long

ReDim myLittleArr(LBound(myArr) To LBound(myArr) + myLen)
For iCtr = LBound(myLittleArr) To UBound(myLittleArr)
myLittleArr(iCtr) = myArr(iCtr)
Next iCtr

With Application
myMax = .Max(myLittleArr)
myMin = .Min(myLittleArr)
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top