PDA

View Full Version : Procedure dependable on multiple constants?



Ako_____
11-27-2010, 01:25 AM
Hi

I want to procedure 1 to be executed when procedure 2 is executed. Also I want procedure 1 to be dependable on multiple constants. For some reason unknown to me the following code doesn't work??? Can somebody help?

The code below works perfectly if I only make procedure 1 dependable on 1 constant?

Sub pro1(a,b,c)
pro1=a+b+c
End Sub

Sub pro2()
a= 1
b= 2
c= 3
pro1(a,b,c)
End Sub

Bob Phillips
11-27-2010, 03:31 AM
pro1 should be a Function if you want it to return a result, which seems to be what you want to do in pro1 but not what you want to do in pro2.

Confused!

Ako_____
11-27-2010, 06:57 AM
Well, yeah I understand why you say that with the code I have written.
However the code above was only ment as an example.

What I really want is that procedure 1 should return a number of values and also visualies some data in a few diagrams.

Can this be done by making procedure 1 as a function?

How come can I get it to work with one constant but not two or above?

Bob Phillips
11-27-2010, 09:49 AM
Sorry, I just don't know what you are asking. What does '... visualies some data in a few diagrams.' mean?

Ako_____
11-27-2010, 11:10 AM
I would like pro 1 to return a number of values. In addition I also want pro 1 to plot some of the results in three graph's.

Bob Phillips
11-27-2010, 11:24 AM
I think that this is the sort of thing you want



Sub pro1(ByRef a, ByRef b, ByRef c)
a = a * 3
b = b * 4
c = c * 5
End Sub

Sub pro2()
a = 1
b = 2
c = 3
Call pro1(a, b, c)

MsgBox a & ", " & b & ", " & c
End Sub

Ako_____
12-12-2010, 12:29 PM
Hi

Unfortunately I have been very busy the few weeks, so I have not had any spare time before know to look at the code you suggested.

I just want to say thanks a lot! It works just as I had hoped it would! :clap: