Android Question Unknown Error on Views

neodd70

Member
Licensed User
I have an app that the code is getting quite long and hard to remember where things are so I wanted to divide my code up into different modules. I have a lot of views comprised of EditText, Button and Label views. I have different sections that change the background image or just reference a view and everything worked fine when it was all in the main Activity Module. But since i have moved my code around to different modules some of the view come up with an error while others do not. I'm not sure what the problem is nor how to fix it. Any help would be greatly appreciated. It's hard to show whats going on with just a few code snippets but I'm not sure how to upload my code either.

Edit: I apologize, I just read that you're not suppose to post screen shots (so I deleted them) but my Main Module has 1000 lines of code and the second module I created isn't as bad but still has over 300 lines. Not sure if I should still attach that much code.
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
You can post the error messages, that will give a clue to the problem. If you have moved views to different modules / layouts, make sure that any Subs relating to those views are in the correct modules.
 
Upvote 0

neodd70

Member
Licensed User
Here is the error I get when I try to upload the app to my tablet.

B4A Version: 8.80
Parsing code. (0.03s)
Building folders structure. (0.01s)
Compiling code. Error
Error compiling program.
Error description: Unknown member: txtlog
Error occurred on line: 22
Main.TXTLog.Text = line & CRLF & Main.TXTLog.Text
Word: txtlog

This is just the first one it catches when I try to upload it. The error I see in the log is the same for all of them "Unknown Member ********"
I haven't moved any of the views. The views are still declared in the main Activity Module. The only thing I'm trying to do is break the code up into different modules so that it is easier to navigate. Some of that code that I want to move does however reference some of the views in that it needs to change a background image or even just populate the EditText with text. When everything was in the Main module it worked fine. It's only started to show the unknown member errors since I tried breaking the code apart.


I tried to zip the project and upload it but the zipped file size was too big so here is a link to it in DropBox

https://www.dropbox.com/s/dokxox8gu5hc5fe/CNC Saw.zip?dl=0
 
Upvote 0

neodd70

Member
Licensed User
That's expected. You cannot access private variables of a different module.

So am I correct in my thinking that I would need to create another variable and use that in my other Class modules and then have the view from the Main Module reference those other Public variables to update the text or background images?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You CAN NOT access a UI Element in Main from any other Modules.

You can call a sub in main to update the view. You can use callsubdelayed (it starts your main) to call a sub in main and update the UI element(s) here.
 
Upvote 0

neodd70

Member
Licensed User
You CAN NOT access a UI Element in Main from any other Modules.

You can call a sub in main to update the view. You can use callsubdelayed (it starts your main) to call a sub in main and update the UI element(s) here.

Right....I get that you CAN NOT access a UI element in Main from any other Sub. What I was asking is if I need to create a variable in my other Modules (VarA) and run my code using that variable and then have a sub in Main reference VarA to update the UI element. For example;

in the WorkOffset Module:

Dim G54X As String

G54X = 10.5

Then in Main


Sub Globals

Private TXTG54X As EditText

End Sub

Sub SetG54

G54X.Text = WorkOffset.G54X

End Sub
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Better save data to a text file, you will have access from any module or consider using the database.
Create a small test project for yourself and you can conduct experiments.
 
Upvote 0
Top