Results 1 to 5 of 5

Thread: Long and boring problem!

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Long and boring problem!

    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:
    1. Private Function picvis(ByVal myIntArray() As Integer)
    2.         Dim x As Integer
    3.         Dim ctl As Control
    4.         x = 0
    5.         For Each ctl In Controls ‘need this loop or does not visit the pictures in order
    6.             If ctl.Tag Is "phone" Then
    7.                 ctl.Visible = True
    8.             End If
    9.         Next
    10.         For Each ctl In Controls
    11.             If ctl.Tag Is "phone" Then
    12.                 If myIntArray(x) = 3 Or myIntArray(x) = 5 Then
    13.                     ctl.Visible = True
    14.  
    15.                 Else
    16.                     ctl.Visible = False
    17.                 End If
    18.                 x = x + 1
    19.  
    20.             End If
    21.         Next
    22.         x = 0
    23.         For Each ctl In Controls ‘need this loop or does not visit the pictures in order
    24.  
    25.             If ctl.Tag Is "DND" Then
    26.                 ctl.Visible = True
    27.                
    28.             End If
    29.         Next
    30.         For Each ctl In Controls
    31.             If ctl.Tag Is "DND" Then
    32.                 If myIntArray(x) = 6 Then
    33.                     ctl.Visible = True
    34.                 Else
    35.                     ctl.Visible = False
    36.                 End If
    37.                 x = x + 1
    38.             End If
    39.         Next
    40.  
    41.     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.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width