E elitistnot Member Licensed User Longtime User Jul 27, 2012 #1 I know this is going to be one of those DUH! question that should be snap for anyone with a little bit of experience with B4A, being new to it I'm still figuring out the basics; How do you access the properties of objects (views or whatever they are called) within code? Something like; label1.text="Testing" does not work. So, what am I doing wrong here? How can I change the text of the label within the code? Thank you for answering my DUH! question, but I can't seem to find an answer in the B4A help document.
I know this is going to be one of those DUH! question that should be snap for anyone with a little bit of experience with B4A, being new to it I'm still figuring out the basics; How do you access the properties of objects (views or whatever they are called) within code? Something like; label1.text="Testing" does not work. So, what am I doing wrong here? How can I change the text of the label within the code? Thank you for answering my DUH! question, but I can't seem to find an answer in the B4A help document.
NJDude Expert Licensed User Longtime User Jul 27, 2012 #2 Actually the line you posted is correct, of course, if you've declared that label, for example, this will change the text of the label: Code: Copy Sub Globals Dim Label1 As Label End Sub Sub Activity_Create(FirstTime As Boolean) Label1.Initialize("") Activity.Addview(Label1, 0dip, 0dip, 320dip, 40dip) Label1.Text = "Hi There" End Sub For some more info about B4A, check the links I have in my signature. Upvote 0
Actually the line you posted is correct, of course, if you've declared that label, for example, this will change the text of the label: Code: Copy Sub Globals Dim Label1 As Label End Sub Sub Activity_Create(FirstTime As Boolean) Label1.Initialize("") Activity.Addview(Label1, 0dip, 0dip, 320dip, 40dip) Label1.Text = "Hi There" End Sub For some more info about B4A, check the links I have in my signature.
E elitistnot Member Licensed User Longtime User Jul 27, 2012 #3 Ok, so the objects created in the Designer are not auto Declared? Ok, so the objects created in the Designer are not auto declared? Or is the label1 you declared in code a different label1 from the one created in the designer? Just sorting out the confusion in my head. I was assuming the objects created in the designer were auto declared in the code. I guess I am wrong there. See, what I am getting at is if I create a label (named label1) in the designer, how can I change the properties (such as the text) in the code in various Subs? Thanks. Last edited: Jul 27, 2012 Upvote 0
Ok, so the objects created in the Designer are not auto Declared? Ok, so the objects created in the Designer are not auto declared? Or is the label1 you declared in code a different label1 from the one created in the designer? Just sorting out the confusion in my head. I was assuming the objects created in the designer were auto declared in the code. I guess I am wrong there. See, what I am getting at is if I create a label (named label1) in the designer, how can I change the properties (such as the text) in the code in various Subs? Thanks.
NJDude Expert Licensed User Longtime User Jul 27, 2012 #4 When you create a view in the designer you have to click on Tools -> Generate members, that will create the line you see in Sub Globals in my sample (Dim Label1 As Label). The views in the designer are not auto-declared but auto-initialized, you should read the documentation to get a better understanding, is not really difficult. Upvote 0
When you create a view in the designer you have to click on Tools -> Generate members, that will create the line you see in Sub Globals in my sample (Dim Label1 As Label). The views in the designer are not auto-declared but auto-initialized, you should read the documentation to get a better understanding, is not really difficult.
E elitistnot Member Licensed User Longtime User Jul 28, 2012 #5 Ahhh.... Ahhh.... See I knew is was a DUH! question. Thanks for helping with that. Your help is very much appreciated. Now, I am off to work on my program feeling idiotic... but all the wiser thanks to you! Upvote 0
Ahhh.... Ahhh.... See I knew is was a DUH! question. Thanks for helping with that. Your help is very much appreciated. Now, I am off to work on my program feeling idiotic... but all the wiser thanks to you!