Results 1 to 5 of 5

Thread: Long and boring problem!

  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  

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Thanks

    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.

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Just create a Control project and you'll see how easy it gets
    \m/\m/

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Pants!!

    Only have VB.net standard edition, and according to the help files

    The Windows Control Library template is not available in the Standard Edition of Visual Basic .NET.

    Any ways around this?

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