Author Topic: Changing colors by bit  (Read 5761 times)

DougLyons

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Changing colors by bit
« Reply #15 on: October 28, 2014, 01:36:35 AM »
MrPike, The "Picturebox.Show" is not a recommended method to use. See this link from Microsoft:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.controls.picturebox.show.aspx

I believe that you should be using the "PictureBox.Visible = True" and "PictureBox.Visible = False" methods to do this.
The problem with using the Show method is that you must balance it with the Hide method when the bit turns off.
This is accounted for in the code that I suggested because the typical "(Value1 and Number)" evaluates to True or False.
This True or False is then applied to the Visible property, so you have the balance here.

If I take your example it might be modified as follows:

 If LabelX.text = 1 then
   PictureBoxX.Show
 Else
   PictureBoxX.Hide
 End if

Also, if you are setting multiple bits at one time you have to be very careful about the Z-ordering of the overlapping boxes.
Previously in this discussion I saw that you had multiple bits set. Is this still the case?
If you are using a particular subset of bits then tell me how the subsets are divided and we can create masks to group them.
Can you make the code work if you use the Label bits as my example showed and then link to these?

Otherwise, if you can paste an example of your code here I can probably do more to help. Thanks.