I'm currently trying to create a maths module (via Compile to Library) however i'm not sure how to get data from a program into the module and then get a result back.
Module Code:
B4X:
Public Sub TKOFactorC(tkobw As String, tkobv As String, tkobc As String)
(tkobw * tkobv * tkobc) / 7000
End Sub
This requires numeric values to be provided from the program and then needs to give TKOFactor back to the program.
Program Code:
B4X:
Sub Button1_Click
Dim MPBM As MNPocketBallistics
Dim a, b, c, d As String
a = "72"
b = "362"
c = "32"
MPBM.Initialize
d = MPBM.TKOFactorC(a,b,c)
Msgbox(d,"")
End Sub
This needs to be able to give the values to the class and then get them back in the form of d.
Any and all help would be great. Its been a long time since I used classes in programming to make functions.
Public Sub TKOFactorC(tkobw As Double, tkobv As Double, tkobc As Double) As Double
Return(tkobw * tkobv * tkobc / 7000)
End Sub
Program code:
B4X:
Sub Button1_Click
Dim MPBM As MNPocketBallistics
Dim a, b, c, d As Double
a = 72
b = 362
c = 32
MPBM.Initialize
d = MPBM.TKOFactorC(a,b,c)
Msgbox(d,"")
End Sub
Thanks for your help. I had the code using strings as it was previously taking data directly from a text field and simply calculating it within an app. Now that its a module, it needs to be done as you've shown, by using Double. Thanks for reminding me that I need to use Double for maths functions, its yet another thing I haven't use for a long time.