Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing an array to a procedure

Status
Not open for further replies.

iamapollo

MIS
Aug 22, 2001
38
AU
Hello

Sorry if this sounds basic but I was wondering how to pass an array of varying lengths to a procedure and then looping through it in vb6.

Thanks in advance for any help

Michael
 
Hey Michael

Maybe this will help. you need a button and textbox on a form.

Option Explicit
Dim dblArr() As Double
Dim dblNum As Double
Dim dblTotal As Double
Dim intCt%, dblTot#

Private Sub Command1_Click()
dblNum = dblNum + 1
ReDim Preserve dblArr(dblNum)
dblArr(dblNum) = dblNum
dblTotal = Pass(dblArr())
Text1.Text = dblTotal
End Sub

Public Function Pass(arr() As Double) As Double
dblTot = 0
For intCt = 0 To UBound(arr)
dblTot = dblTot + arr(intCt)
Next
Pass = dblTot
End Function

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top