William Hunter Active Member Licensed User Longtime User May 2, 2012 #1 I am trying to change label text programmatically. The label has been declared in Globals and initiated in Activity_Create. The code for the text change is in another sub. I have been able to make similar text changes with buttons, but can’t seem to do this with labels. Any help would be appreciated. :sign0085:
I am trying to change label text programmatically. The label has been declared in Globals and initiated in Activity_Create. The code for the text change is in another sub. I have been able to make similar text changes with buttons, but can’t seem to do this with labels. Any help would be appreciated. :sign0085:
NJDude Expert Licensed User Longtime User May 2, 2012 #2 To change the text of a label: Code: Copy Label1.Text = "Some Text" Maybe there's something else in your code, but without seeing it is just a guessing game. Upvote 0
To change the text of a label: Code: Copy Label1.Text = "Some Text" Maybe there's something else in your code, but without seeing it is just a guessing game.
klaus Expert Licensed User Longtime User May 2, 2012 #3 It's the same as with Buttons. Label1.Text = somestringvariable or Label1.Text = "some text". If the label is defined in a layout file you must NOT initialize it in Activity_Create ! Otherwise you are initiating a new instance and have no acces to the one difined in the layout file. Best regards. Upvote 0
It's the same as with Buttons. Label1.Text = somestringvariable or Label1.Text = "some text". If the label is defined in a layout file you must NOT initialize it in Activity_Create ! Otherwise you are initiating a new instance and have no acces to the one difined in the layout file. Best regards.
lagore Active Member Licensed User Longtime User May 2, 2012 #4 To change the label text it is just Code: Copy lb.Text = "One" this can be done in the labels activity but not from another module. Upvote 0
To change the label text it is just Code: Copy lb.Text = "One" this can be done in the labels activity but not from another module.
William Hunter Active Member Licensed User Longtime User May 2, 2012 #5 Changing label text programatically klaus said: If the label is defined in a layout file you must NOT initialize it in Activity_Create ! Otherwise you are initiating a new instance and have no acces to the one defined in the layout file. Click to expand... Thank you all for your response. Klaus correctly identified my error. I had initialized in Activity_Create. :signOops: All is now well. Regards Upvote 0
Changing label text programatically klaus said: If the label is defined in a layout file you must NOT initialize it in Activity_Create ! Otherwise you are initiating a new instance and have no acces to the one defined in the layout file. Click to expand... Thank you all for your response. Klaus correctly identified my error. I had initialized in Activity_Create. :signOops: All is now well. Regards
wegmanjunior New Member Oct 24, 2012 #6 why do i then get this as error: Code: Copy Error description: Undeclared variable 'Label1' is used before it was assigned any value. Upvote 0
why do i then get this as error: Code: Copy Error description: Undeclared variable 'Label1' is used before it was assigned any value.
klaus Expert Licensed User Longtime User Oct 24, 2012 #7 You don't give enough information ! Where and how do you define Label1 ? - in a layout file ? - in the code ? Do you Dim Label1 As Label in the Globals routine ? Best regards. Upvote 0
You don't give enough information ! Where and how do you define Label1 ? - in a layout file ? - in the code ? Do you Dim Label1 As Label in the Globals routine ? Best regards.
O olivlaytchev New Member Licensed User Longtime User Oct 10, 2014 #8 Hi, if I would like to have certain output (which is a combination of variables and text) from the label such as : 'result.Text = "Your annual return in % is: " annualReturn " and your investment will be returned in "years" years."'. How do I correctly concatenate the variables' value with the text?? Help is appreciated Upvote 0
Hi, if I would like to have certain output (which is a combination of variables and text) from the label such as : 'result.Text = "Your annual return in % is: " annualReturn " and your investment will be returned in "years" years."'. How do I correctly concatenate the variables' value with the text?? Help is appreciated
udg Expert Licensed User Longtime User Oct 10, 2014 #9 Are you meaning this? Code: Copy result.Text = "Your annual return in % is: " & annualReturn &" and your investment will be returned in " &years &" years."'. udg Upvote 0
Are you meaning this? Code: Copy result.Text = "Your annual return in % is: " & annualReturn &" and your investment will be returned in " &years &" years."'. udg
O olivlaytchev New Member Licensed User Longtime User Oct 10, 2014 #10 udg said: Are you meaning this? Code: Copy result.Text = "Your annual return in % is: " & annualReturn &" and your investment will be returned in " &years &" years."'. udg Click to expand... exactly, thanks a lot Upvote 0
udg said: Are you meaning this? Code: Copy result.Text = "Your annual return in % is: " & annualReturn &" and your investment will be returned in " &years &" years."'. udg Click to expand... exactly, thanks a lot