Android Question Lookup differences between Sub, Private Sub, and Public Sub

Mikelgiles

Active Member
Licensed User
Longtime User
Where can I find help on differences between Sub, Private Sub, and Public Sub. Also am I OK using two forms but only only one (Main) module?
 

Mikelgiles

Active Member
Licensed User
Longtime User
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
Looks like this query should be in B4J forums, not B4A.
My bad! I need to review better. I really thought I had put it in as a B4J Question. I will make it a practice to review every post in the future. Thanks for pointing it out.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Opps! VB6 term I guess. Two windows(pages?), mainform.bjl and detail.bjl and just one module, main. All of the code is in the main module and I am wondering if that is a bad practice as in the Threepages example there is a main module plus a module( .bas file) for each of the pages..
I didn't know that tutorial and those examples, so thank you, Mike ;) (perhaps I should also thank Erel for developing those examples :p. Thanks, Erel).

1) VB6 term - in B4J Forms are... forms, as in VB6. In the Threepages example, Erel created and added to the project 2 code modules (icon:
upload_2019-10-31_2-37-44.png
), specifically "named" LoginForm and UserForm just to confuse you :p (sooner or later I'll be able to write a post without joking... I hope :D), Main is automatically added when you create a new project. Within each of these two code modules a Form is created and this is not mandatory, it is an Erel's design choice:
B4X:
' CODE MODULE - named LoginForm
Sub Process_Globals
    Private frm As Form ' Declaration of an object variable named "frm" of type Form - Form is a "window", as in VB6
'...

Public Sub Show
   If frm.IsInitialized = False Then
       frm.Initialize("frm", 400, 400)
       frm.RootPane.LoadLayout("Login") ' <-- Here Erel loads A layout (containing "Views" - VB6 controls) he created, voluntary named Login,
'                                             using the Designer, generating so a .bjl file (a "layout file").
'                                             The Login layout is loaded in a "control" (node in b4j) of type AnchorPane named RootPane,
'                                             which is always present by defaul in every Form you create, it is the fundamental basis.
' ...

If you want to create a master/detail form (named frmMain?), you can use just one code module, the Main, if you want, creating the form "inside" it (see above) and a single layout (using the Designer) for both the Master and the Details GUI parts you will load into the frmMain.RootPane.


[Who knows how many nonsense I wrote: it's 3 am and I'm almost asleep :D]
 
Last edited:
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
If you want to create a master/detail form (named frmMain?) said:
code module[/U], the Main, if you want, creating the form "inside" it (see above) and a single layout (using the Designer) for both the Master and the Details GUI parts you will load into the frmMain.RootPane.


[Who knows how many nonsense I wrote: it's 3 am and I'm almost asleep :D]

No nonsense that I see and I thank you for the detailed explanation! Looks like it is OK to do more than one form in the main module and that is what i was wondering about. Most of the time I prefer one module unless I want to share part of the code with another program or the app just gets too large. I had already changed my app to use two modules and got it working so I will leave it like that( I have a problem with changing things that are already working LOL) but I really do thank you for the explanation for future work!
 
Upvote 0
Top