ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   SUBROUTINE HELP (https://www.excelbanter.com/excel-discussion-misc-queries/152089-subroutine-help.html)

biker man

SUBROUTINE HELP
 

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??


Dave Peterson

SUBROUTINE HELP
 
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




biker man wrote:

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??


--

Dave Peterson


All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com