passing a module name as a variable

Cableguy

Expert
Licensed User
How can I do this?
If I want to use 1 module and its forms consist of reusable panels, wich I change the parent....How to refer to a module using a string variable, in or der to callback a public sub from that module, commom to all modules...
If there's not yet a Keyword for it, it probably would be a good time to add a "Module(string)" keyword...
 

Ricky D

Well-Known Member
Licensed User
not sure exactly what you're saying

but I'll try.

In my taxi app i use "Shifts.frmShifts" and that works where code requires the form in the Shifts module. I have a panel on frmShifts that I use on 2 other forms. Here is a menu click sub that changes the parent of the panel then runs a sub in Utils that sets up the data on the panel and finally brings it to the front and makes it visible.

Sub mnuShiftStatsEdit_Click
flibFareEdit.ChangeParent("shifts.pnlShiftStats","frmFareEdit")
utils.CalcShiftStats
shifts.pnlShiftStats.Visible=True
shifts.pnlShiftStats.BringToFront
End Sub

I hope this might help you.

regards, Ricky
 

Cableguy

Expert
Licensed User
That works if you hard code the module name, but I want to pass it as a variable, in a string...

Control(modulename).modulesub does not work...
 

Cableguy

Expert
Licensed User
You should use:
B4X:
CallSub(ModuleName & "." & subName)
You can see an example of using a callback sub in the FolderChooser sample (c:\Program Files\Anywhere Software\Basic4ppc Desktop\Samples).
I HAD FORGOTTEN ALL ABOUT CALLSUB, AS i NEVER HAD USED IT BEFORE....

BTW: MY FORMLIB PROBLEM IS SOLVED...
 
Last edited:
Top