Or you can create your own complex type, structure, like:
//Window1.calcTriple:
Function calcTriple(n As Double = 1.0) As Triple
Dim t As Triple?
t.x = n*2.34
? t.y = n*3.14
t.z = n*4.56
Return t
End Function
Structure Triple
x as Double
? y As Double
? z As Double
End Structure
//Window1 Control PushButton1:
Sub Action()
? Dim v As Triple = calcTriple(10)
?MsgBox "x= " +Str(v.x)+ " , y= " +Str(v.y)+ " , z= " +Str(v.z)
End Sub
[quote]
Beatrix Willius
2 hours ago Beta Testers Europe (Germany)
What do you mean with “doesn’t work”? Haven’t used byref in ages, though. You could return an array of doubles.[/quote]
My function is declared as follows: LBR_For_Lune( At_JDE as double, ByRef L as double, ByReF B as double, ByRef R as double) as double
Using sub with return value empty, i get this msg:
parameters are not compatible with this function
ClsP.LBR_For_Lune(At_JDE,L,B,R)
using function with return value double, i get this msg:
You must use the value returned by this function
ClsP.LBR_For_Lune(At_JDE,L,B,R)
in a Module Astro i have several class, LBR_For_Lune is in ClsP.
Dim ClsP as New Astro.ClsP
Are you sure that At_JDE, L, B, and R are declared as doubles in the ClsP module somewhere? The method that calls your function does not know the names of the variables – it simply sees that your function is requesting four doubles, which you have to separately define in the calling method.
I also suspect that when you return the double, you are still getting first error, it is just that the second one supersedes it.
[quote=101206:@Djamel AIT AMRANE]Using sub with return value empty, i get this msg:
parameters are not compatible with this function
ClsP.LBR_For_Lune(At_JDE,L,B,R)[/quote]
If you define a function with a return value you either have to use it, or you have to use CALL:
Dim myVar As Double = ClsP.LBR_For_Lune(At_JDE,L,B,R)
[quote=101144:@Djamel AIT AMRANE] :
Calc(a as double, ByRef x as double, ByRef y as double,ByRef z as double) as double
x= a * 10
y= a * 100
z= a * 1000
return[/quote]
Function Calc1(a as double, ByRef x as double, ByRef y as double,ByRef z as double) as double
Dim AnyValue as Double = 1234.5678
x= a * 10
y= a * 100
z= a * 1000
return AnyValue
End Function
Sub Calc(a as double, ByRef x as double, ByRef y as double,ByRef z as double)
x= a * 10
y= a * 100
z= a * 1000
return // Optional here
End Sub
[quote]
Thomas Moore
57 minutes ago Beta Testers, Xojo Pro, IOS Alpha Testers Claremont, CA
Are you sure that At_JDE, L, B, and R are declared as doubles in the ClsP module somewhere? The method that calls your function does not know the names of the variables – it simply sees that your function is requesting four doubles, which you have to separately define in the calling method.
I also suspect that when you return the double, you are still getting first error, it is just that the second one supersedes it.[/quote]
Function is defined as double, variables as double, L,B,R are ByRef.
I have found that inside the functions had same name of out put values, i change L, B to LL, BB , and it’s running properly.
i am new in Xojo, i discover it, i must thing differently as Vb6.
I am converting Vb appllications to Xojo and learning xojo together.
thank’s everybody.
You are right, the function was modified to run with other special maths functions, so have rewrite some variables, and i make some mistakes.
Thank you.