I did look at CallSub.. but. it dosnt do the trick. Perhaps im missing something here.
Since TYPE cant hold anything else than Data, I need a way to parse various SUBs (but only parse 1 for every call) with different calculation so I dont have to make all the code inside one SUB, and the called SUB can have multible function with the same data.
Hope this make sense.. English is not really my language
Sub CalcOne(v As Int) As Int
Return v * 2
End Sub
Sub CalcTwo(v As Int) As Int
Return v * 4
End Sub
Sub PutValue(v As Int) As Int
rList.add(v)
Return v
End Sub
Sub GetValue(v As Int) As Int
Return rList.Get(v)
End Sub
Sub MinValue(a As Int, b As Int) As Int
If a < b Then Return a Else Return b
End Sub
Sub MaxValue(a As Int, b As Int) As Int
If a > b Then Return a Else Return b
End Sub
Sub RunData(GoValue As (e.g) Sub, Statement As Sub)
'
' Here i run the Data.
'
End Sub
Sub Init
RunData(CalcOne, MinValue)
RunData(PutValue, MaxValue)
End Sub
Type MyType ( _
Name As String, _
Items(10) As Int, _
Init as String, _
GetValue as String, _
...
)
Then assign Init = "Init" (the name of the sub)
and wherever you need to call it just use CallSub(Main,MyType1.Init)
etc...
Another better way is just to use a Code module as an object definition.
But in that case you can only have 1 instance of the object, not multiple.
They way around that would be to create an object definition by a Type and pass that over to the code module's subs.
Sub Test1S(msg As String)
Msgbox(msg,"Test1")
End Sub
Sub Test2S(msg As String)
Msgbox(msg,"Test2")
End Sub
Sub CallString(subname As String, param As String)
Dim Obj1 As Reflector
subname = "_" & subname.ToLowerCase
Obj1.RunStaticMethod("your.package.name.main", subname, Array As Object(param), Array As String("java.lang.String"))
End Sub
Sub Btn1_Click
CallString("Test1S", "Calling")
CallString("Test2S", "Calling")
End Sub
This can be extended to any Sub with any mix of parameter types
It would be nice to either get TYPE inherited from other TYPE with subs-override or perhaps get less lucky and have the possibility of using
sub calls as descriebed in above posts (the easy way. hehe)
My question: Can we expect something like this in future updates?
Actually, he is on to something here. It would be rather neat if I could specify a variable/argument as "Method" or "Call" or something like that. then, when I use it, internally, but hidden from me, of course CallSub or Reflection is used.
The code would be clearer, and it would require less "under the hood-knowledge".