I would like some help really. Last week I wrote a bit of code to solve a problem I had. Basically I have a list of 40 text boxes and next to each text box are two pictures. I re-populate the contents of these text boxes every two seconds using a timer. The data comes from a MySQL database. Anyway the contents of these text boxes is constantly changing. I have two pictures next to each text box which I either make visible or not depending on an associated value from the mysql database.
Enough waffle, please find an attached picture of the form in operation.
My problem is that I'm making the picture appear and disappear by recording the associated value in an array while I'm populating the text boxes. I then pass the array to the following method
VB Code:
Private Function picvis(ByVal myIntArray() As Integer) Dim x As Integer Dim ctl As Control x = 0 For Each ctl In Controls ‘need this loop or does not visit the pictures in order If ctl.Tag Is "phone" Then ctl.Visible = True End If Next For Each ctl In Controls If ctl.Tag Is "phone" Then If myIntArray(x) = 3 Or myIntArray(x) = 5 Then ctl.Visible = True Else ctl.Visible = False End If x = x + 1 End If Next x = 0 For Each ctl In Controls ‘need this loop or does not visit the pictures in order If ctl.Tag Is "DND" Then ctl.Visible = True End If Next For Each ctl In Controls If ctl.Tag Is "DND" Then If myIntArray(x) = 6 Then ctl.Visible = True Else ctl.Visible = False End If x = x + 1 End If Next End Function
Can any clever chaps think of a better way to do this, as the way I'm doing it is just feels plain wrong.




Reply With Quote