Roger Daley Well-Known Member Licensed User Longtime User Jan 26, 2015 #1 Hi All, I know I should know this one, but the brain cells just don't click. I have a number of lables lblF0 - lblF15 in which the textcolour changes. At some point I need to preserve the current text colours. I have attempted to do this in a for/next in various ways but all have failed. Below was the code starting point but this stores a string [eg "lblF1.TextColor"] not the color number. Code: Dim Fcolours(16) As String For FCol = 0 To 15 Fcolours(FCol) = "lblF"&FCol&".TextColor" Next Regards Roger
Hi All, I know I should know this one, but the brain cells just don't click. I have a number of lables lblF0 - lblF15 in which the textcolour changes. At some point I need to preserve the current text colours. I have attempted to do this in a for/next in various ways but all have failed. Below was the code starting point but this stores a string [eg "lblF1.TextColor"] not the color number. Code: Dim Fcolours(16) As String For FCol = 0 To 15 Fcolours(FCol) = "lblF"&FCol&".TextColor" Next Regards Roger
NJDude Expert Licensed User Longtime User Jan 26, 2015 #2 Save those values in the label's TAG. Upvote 0
Roger Daley Well-Known Member Licensed User Longtime User Jan 26, 2015 #3 NJDude said: Save those values in the label's TAG. Click to expand... Sorry NJDude, Can you be more explicit? Saving the values isn't really the problem, getting them via recursion instead of 16 lines of code to get them one by one is the problem. Regards Roger Upvote 0
NJDude said: Save those values in the label's TAG. Click to expand... Sorry NJDude, Can you be more explicit? Saving the values isn't really the problem, getting them via recursion instead of 16 lines of code to get them one by one is the problem. Regards Roger
NJDude Expert Licensed User Longtime User Jan 26, 2015 #4 You will have to create an array of labels if you want to use a loop, otherwise, you will have to write 16 lines of code. Upvote 0
You will have to create an array of labels if you want to use a loop, otherwise, you will have to write 16 lines of code.
M Mahares Expert Licensed User Longtime User Jan 26, 2015 #5 @NJDude: I was thinking something like this. Can we get your blessing: Code: Dim arrLabel(16) As Label For i=0 To arrLabel.Length-1 arrLabel(i).Tag=arrLabel(i).TextColor Next Upvote 0
@NJDude: I was thinking something like this. Can we get your blessing: Code: Dim arrLabel(16) As Label For i=0 To arrLabel.Length-1 arrLabel(i).Tag=arrLabel(i).TextColor Next
stevel05 Expert Licensed User Longtime User Jan 26, 2015 #7 If you can now read the colour directly from the Label, do you need to store it somewhere else? Edit, sorry should have reread the first post. Upvote 0
If you can now read the colour directly from the Label, do you need to store it somewhere else? Edit, sorry should have reread the first post.
Roger Daley Well-Known Member Licensed User Longtime User Jan 26, 2015 #8 NJDude said: Bless you my son. Click to expand... Upvote 0
Roger Daley Well-Known Member Licensed User Longtime User Jan 26, 2015 #9 stevel05 said: If you can now read the colour directly from the Label, do you need to store it somewhere else? Edit, sorry should have reread the first post. Click to expand... Steve105, I should have said in first post the text colour in the label indicates if there is an associated function. In some modes all these functions are disabled and re-enabled in the original mode. Therefore I need to save the text colour when leaving on mode and restore it when returning. I thought a For/Next loop would be simple, I have gone for the 16 lines of code solution. Thanks for the reply Roger Upvote 0
stevel05 said: If you can now read the colour directly from the Label, do you need to store it somewhere else? Edit, sorry should have reread the first post. Click to expand... Steve105, I should have said in first post the text colour in the label indicates if there is an associated function. In some modes all these functions are disabled and re-enabled in the original mode. Therefore I need to save the text colour when leaving on mode and restore it when returning. I thought a For/Next loop would be simple, I have gone for the 16 lines of code solution. Thanks for the reply Roger