cncmachineguy
Member
- Joined
- Aug 3, 2013
- Messages
- 8
- Programming Experience
- 10+
I have done some searching for this both here and google. As you can imagine using array and control or button gets LOTS of hits. So if I am re-hashing an already answered question please be kind.
I am trying to create a GUI as a front end to an I/O card I have built. It enumerates over USB as a HID device. All works fine there. What I have so far is 2 groups of 14 buttons that represent pins on my board. My firmware sends back the state of all pins and VB parses to decide on what color a button should be. I like using the buttons as they work well as dual purpose in my app. I can set a pin or read it using just the button.
Here is where I need help-
I have an array called PinColor() as Color.
Once I have all the colors set, I then have 28 lines of code:
now it occurs to me there must be a better way to assign the color value to each button. I can live with it for 28 pins, but I have 85 total and just can't imagine there is not a better way.
this is what I would like to do but assume it won't work since I can't name the buttons with an index (at least I don't know how):
I am trying to create a GUI as a front end to an I/O card I have built. It enumerates over USB as a HID device. All works fine there. What I have so far is 2 groups of 14 buttons that represent pins on my board. My firmware sends back the state of all pins and VB parses to decide on what color a button should be. I like using the buttons as they work well as dual purpose in my app. I can set a pin or read it using just the button.
Here is where I need help-
I have an array called PinColor() as Color.
Once I have all the colors set, I then have 28 lines of code:
VB.NET:
button1.backcolor = pincolor(0)
now it occurs to me there must be a better way to assign the color value to each button. I can live with it for 28 pins, but I have 85 total and just can't imagine there is not a better way.
this is what I would like to do but assume it won't work since I can't name the buttons with an index (at least I don't know how):
VB.NET:
dim i as integer
for i = 0 to 27
button(i).BackColor = PinColor(i)
next