How do I do this?

Shay

Well-Known Member
Licensed User
Longtime User
dim i as string
i="red"
Button.color=Colors.i

tried few combination without luck
 

Shay

Well-Known Member
Licensed User
Longtime User
is there any simplier way to do this (pass value)
this is only example for what I am trying to
the main goal is quite more complicated than that
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
is there any simplier way to do this (pass value)
Pass a value to what ? Colors.Red is a constant.

B4X:
the main goal is quite more complicated than that
What is your complicated main goal ?

You asked a simple question and you got simple answers!
If you expect more precise advices you must also expose the problem you want to solve more precisely.

Best regards.
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I will try to explain the problem

I have 2 x 10 buttons
each 10 buttons must have the same color

I have 2 sets of 8 colors, in which i need to choose 2 colors
after I choose the color (by pressing the button)
the 10 buttons need to get the background color, from what I choose
same for the second 10 buttons
(total i need to choose 2 colors - 1 of 8 and again 1 of 8 colors)

each 10 buttons cannot have the same color as the other 10
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
How do you choose the colors ?
You say you have two sets of 8 colors, how are they defined or where do they come from ?
Are the two sets different ?

You can define two arrays
Dim Colors1(7) as Int
Dim Colors2(7) as Int
Colors1(0) = Colors.Red
Colors1(1) = Colors.Blue
.
.
.

Colors2(0) = Colors.Yellow
Colors2(1) = Colors.Green
.
.

Button1.Color = Colors1(2)
Button2.Color = Colors1(2)
.
.
Button9.Color = Colors2(4)
Button10.Color = Colors2(4)

Best regards.

@dealsmonkey
dim i as string
i = "colours.Red"
Button.color = i

this won't work
it should be
Dim i as Int
i = Colours.Red
Button.Color = i

Best regards.
 
Upvote 0
Top