Calling a function from a subroutine loop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is a subroutine and function that I cannot work out or find help on.
I'm trying to call a function in a subrouting, and then have the function
calculated inside a loop for changing variable values. Any advice would be
appreciated. Dan

Public Function CR(Y, X, Z)
Y = X^Z
End Function

Sub CalcCR()

Call CR(Y, X, Z)
X = 2
Z = 3
alpha = 1

For i = 1 to 10
X = X + Y
Next i

End Sub
 
Public Function CR(Y, X, Z)
Y = X^Z
CR = Y
End Function

Sub CalcCR()

X = 2
Z = 3
alpha = 1

For i = 1 to 10
results = CR(Y, X, Z)
msgbox "X=" & X & " Results: " & results
X = X + Y
Next i

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

Back
Top