E edm68 Member Licensed User Longtime User May 31, 2014 #1 I've never used modules before and am trying to tidy up my Main by breaking off into smaller modules. Hope that makes sense. What I'm trying to do now is just populate a spinner from a different module. I've tried numerous variations and have attached my latest attempt. Not sure if I'm even using the proper type of module? I was trying to use Erel's static code module tutorial as an example, but don't know what to put in the Main. Thanks Attachments test1.zip test1.zip 6.9 KB · Views: 243
I've never used modules before and am trying to tidy up my Main by breaking off into smaller modules. Hope that makes sense. What I'm trying to do now is just populate a spinner from a different module. I've tried numerous variations and have attached my latest attempt. Not sure if I'm even using the proper type of module? I was trying to use Erel's static code module tutorial as an example, but don't know what to put in the Main. Thanks
derez Expert Licensed User Longtime User May 31, 2014 #2 Code module cannot have views and spinner is a view. Since you put the spinner in the main layout, you have it in the main activity. The module cannot access it because it is a view, but you can get the data from there and fill it in the main. in main: Code: Copy Sub myStart spnTest.AddAll(fillSpinners.fill_spnTest) End Sub in module: Code: Copy Public Sub fill_spnTest as string() Dim str() as string = Array As String("a","b","c","d")) Return str End Sub Upvote 0
Code module cannot have views and spinner is a view. Since you put the spinner in the main layout, you have it in the main activity. The module cannot access it because it is a view, but you can get the data from there and fill it in the main. in main: Code: Copy Sub myStart spnTest.AddAll(fillSpinners.fill_spnTest) End Sub in module: Code: Copy Public Sub fill_spnTest as string() Dim str() as string = Array As String("a","b","c","d")) Return str End Sub
klaus Expert Licensed User Longtime User May 31, 2014 #3 You could also do it like this, passing the Spinner in the calling routine: in main: Code: Copy Sub myStart fill_Spinner(spnTest, Array As String("a","b","c","d")) End Sub in module: Code: Copy Public Sub fill_Spinner(spn As Spinner, str as string()) spn.AddAll(str) End Sub For me, filling a spinner in a code mocule is not efficient. Instead of the code above you would have only one line in the activity module. Code: Copy spnTest.AddAll(Array As String("a","b","c","d")) But at least you see the principle. Upvote 0
You could also do it like this, passing the Spinner in the calling routine: in main: Code: Copy Sub myStart fill_Spinner(spnTest, Array As String("a","b","c","d")) End Sub in module: Code: Copy Public Sub fill_Spinner(spn As Spinner, str as string()) spn.AddAll(str) End Sub For me, filling a spinner in a code mocule is not efficient. Instead of the code above you would have only one line in the activity module. Code: Copy spnTest.AddAll(Array As String("a","b","c","d")) But at least you see the principle.
E edm68 Member Licensed User Longtime User May 31, 2014 #4 Thanks for the replies, will definitely check these out tomorrow. I was just looking for an example of how to do this from another module as I've never used modules before and have a few spinners that I will need to fill, eventually from database. I just thought it might be less confusing for me if I could break it off into a module so that once I get that correct I could concentrate on other aspects. Thanks Upvote 0
Thanks for the replies, will definitely check these out tomorrow. I was just looking for an example of how to do this from another module as I've never used modules before and have a few spinners that I will need to fill, eventually from database. I just thought it might be less confusing for me if I could break it off into a module so that once I get that correct I could concentrate on other aspects. Thanks
klaus Expert Licensed User Longtime User May 31, 2014 #5 If you want to fill Spinners from a database you should have a look at DBUtils. You could also have a look at chapter 4 DBUtils in the User's Guide ? Upvote 0
If you want to fill Spinners from a database you should have a look at DBUtils. You could also have a look at chapter 4 DBUtils in the User's Guide ?