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.
I can't view your picture because my firewall is blocking the content, but I think I understood what you were saying based on your desc. and code.
If I were you, I would make a custom control with the two pictures and the textbox all in one. On the change event of the textbox, you update the pictures. Now there is no need to keep track of the pesky arrays and trying to figure out which pictures map to which picture.
Thanks sounds good, have no idea how to do this so any help would be great.
Am going to try and search through my VB.Net book to see what it says. Probably something useful like ............ well have just looked and it says nothing!!. Suppose it's only an introducton to VB.net, I'll have to see what the cryptic help files say.