J Junctbr Member Dec 4, 2018 #1 First Activity Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Public myVar As String End Sub Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") myVar = etName.Text End Sub Second Activity: Code: Copy Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: Activity.LoadLayout("layout2") lblUser.Text = Main.myVar End Sub The result is ("blank") I want to display in lblUser.text in 2nd activity the name I input at etName.Text Thanks in advance for any tips. ^^
First Activity Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Public myVar As String End Sub Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") myVar = etName.Text End Sub Second Activity: Code: Copy Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: Activity.LoadLayout("layout2") lblUser.Text = Main.myVar End Sub The result is ("blank") I want to display in lblUser.text in 2nd activity the name I input at etName.Text Thanks in advance for any tips. ^^
Erel B4X founder Staff member Licensed User Longtime User Dec 4, 2018 #2 Add this sub to the second Activity: Code: Copy Sub StartAndSetText(Text As String) lblUser.Text = Text End Sub In the first activity use this code to start the second activity instead of StartActivity: Code: Copy CallSubDelayed2(Activity2, "StartAndSetText", "any text you like") More information: Using CallSubDelayed to interact between activities and services Upvote 0
Add this sub to the second Activity: Code: Copy Sub StartAndSetText(Text As String) lblUser.Text = Text End Sub In the first activity use this code to start the second activity instead of StartActivity: Code: Copy CallSubDelayed2(Activity2, "StartAndSetText", "any text you like") More information: Using CallSubDelayed to interact between activities and services