Combobox color change

If I have a combobox with colors listed in it, how would I use a selected color from the combobox to change the backgound color of a textfield.

Thanks Shane

The answer depends on how the colors are listed. If you have your colors listed as rgb values (255, 0, 0) or hex values &cFF0000, then you can just get the combobox text as a variant and apply that as a color.
Assuming you have the colors as text: Red, Green, Blue, etc, create a dictionary to define a color from the text.

Dim d As new dictionary d.value("Red") = &cFF0000 d.value("Green") = &c00FF00 d.value("Blue") = &c0000FF

Then from your combobox…

Dim myColor As string = combobox1.Text if d.hasKey(myColor) Then textField1.backcolor = d.value(myColor) end if

Thanks Roger, what events would I put them in.

Thanks Shane

Define your dictionary once only. Maybe in a separate module, or in the app class.
Then just call to it from the change event of the combo box

what would I need to change for it to change the color of multiple textfields at once.

Thanks Shane.

Many thanks Roger, have it working fine.

Cheers Shane.