I'm trying to come up with a simple calcutation tool for an on-line game called travian...
I'm trying to automatiza the calculation of the time nned to travel from point a to b at a given speed...
For the ones not fammyliarized with the game,,, The units have diferents seepds, measured in squares per hour...
So, since I don't want to repeat the same code over and over, I thought about creating a calculation sub and pass the parameters...
But they are not being passed...
I just can't fugure out...
Code:
..... n=VLeg Calculos(d,ds,fx,n) Msgbox(TS) End Sub
Sub Calculos v=3600/n Msgbox(v) TS=(v*d)+((v*fx)*ds) Format(TS,"n2") Return(TS) End Sub
Any thoughts?
I'm also trying to convert seconds to the time format (HH:MM:SS), any one have done that yet?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
since we have local variables, you have to define the parameters in the called sub again:
Sub Calculos(d,ds,fx,n)
...
End Sub
Cheers
specci48
I knew I was forgetting something....dahm....
Thnks Specci...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
Ok, so calculations now occur but the TS var is not returned to the calling sub....Any thoughts????
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
Ends the current sub and returns to the calling sub.
If Return is followed by a value, then the value will be passed to the calling sub.
Syntax: Return [Value]
Example:
Sub Button1_Click
If IsInteger (a) = true Then b=a
End Sub
Sub IsInteger (x)
If x = Int(x) Then Return true Else Return false
End Sub
So the code SHOULD work but it gives an "input in the wrong format" kind of error...
Solved:the paramters returned do not need to be inside brackets.....
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
Last edited by Cableguy : 11-30-2007 at 07:21 PM.
Reason: found my error...
TS= some mathematical operation
MsgBox(TS) ' Does show the result from the previous line...
Return TS ' Nothing is passed to the calling sub, WHY????
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!