mrumball Member Licensed User Longtime User Jan 12, 2021 #1 Hi, I have a common sub routine that operates on 2 different pages, how do I send the page information to the sub? I am currently using a string to hold the sender page then use SELECT to work out which page to operate on, this works but is messy, I am sure that there is a cleaner way. Can anyone help? B4X: Copy Public Sub TestSub(senderpage As String) Select senderpage Case "STOCK_LOCATE" B4XPages.MainPage.Page_STOCK_LOCATE.LblPartDescription.Text = "Part number not found" Case "STOCK_OUT" B4XPages.MainPage.Page_STOCK_OUT.LblPartDescription.Text = "Part number not found" End Select End Sub
Hi, I have a common sub routine that operates on 2 different pages, how do I send the page information to the sub? I am currently using a string to hold the sender page then use SELECT to work out which page to operate on, this works but is messy, I am sure that there is a cleaner way. Can anyone help? B4X: Copy Public Sub TestSub(senderpage As String) Select senderpage Case "STOCK_LOCATE" B4XPages.MainPage.Page_STOCK_LOCATE.LblPartDescription.Text = "Part number not found" Case "STOCK_OUT" B4XPages.MainPage.Page_STOCK_OUT.LblPartDescription.Text = "Part number not found" End Select End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 12, 2021 #2 Code: Copy Public Sub TestSub(senderpage As Object) CallSub2(senderpage, "SetDescription", "Part number not found") End Sub Upvote 0
Code: Copy Public Sub TestSub(senderpage As Object) CallSub2(senderpage, "SetDescription", "Part number not found") End Sub
mrumball Member Licensed User Longtime User Jan 12, 2021 #3 Thanks for your quick reply Erel, I may have not explained what I am looking to achieve, I want to send 'B4XPages.MainPage.Page_STOCK_LOCATE' or 'B4XPages.MainPage.Page_STOCK_OUT' to the sub B4X: Copy Public Sub TestSub(senderpage As Object) senderpage.LblPartDescription.Text = "Part number not found" End Sub The above does not work Thanks Upvote 0
Thanks for your quick reply Erel, I may have not explained what I am looking to achieve, I want to send 'B4XPages.MainPage.Page_STOCK_LOCATE' or 'B4XPages.MainPage.Page_STOCK_OUT' to the sub B4X: Copy Public Sub TestSub(senderpage As Object) senderpage.LblPartDescription.Text = "Part number not found" End Sub The above does not work Thanks
LucaMs Expert Licensed User Longtime User Jan 12, 2021 #4 Do not send the page id, send directly the label. B4X: Copy Public Sub TestSub(LblPartDescription As B4XView) LblPartDescription.Text = "Part number not found" End Sub Upvote 0
Do not send the page id, send directly the label. B4X: Copy Public Sub TestSub(LblPartDescription As B4XView) LblPartDescription.Text = "Part number not found" End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 13, 2021 #5 You can pass the label directly as suggested above. What I meant, is that you will add a "SetDescription" sub in each of the pages and call it with CallSub. Upvote 0
You can pass the label directly as suggested above. What I meant, is that you will add a "SetDescription" sub in each of the pages and call it with CallSub.