Results 1 to 5 of 5

Thread: what am I doing wrong

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I have a lot of labels (label1) and I made them all a label control array I also have shapes which I also made into a control array, I made sure that there is the same of both. my goal is to make it so that is label1(1).visible = false, then shape1(1).visible = false. but I dont want to write it out for every single label and shape so I tried this code and it did not work, whats wrong with is:

    Code:
    if label1(index as Integer).Visible = False  then
    shape1(index as Integer).Visible  = False
    End If
    if the code is just stupid can someone please give me the correct
    NXSupport - Your one-stop source for computer help

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    74
    assuming u have n labels and shapes

    for index = 1 to n
    shape1(index).visible = label1.visible
    next index

    it can be done more nicely with a for each loop, but i cant rem how at the moment


  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks
    NXSupport - Your one-stop source for computer help

  4. #4
    Guest
    Or you could do this:

    Code:
    Dim MyControl As Control
    For Each MyControl In Me.Controls
        If TypeOf MyControl Is Label Then MyControl.Visible = False
        If TypeOf MyControl Is Shape Then MyControl.Visible = False
    Next

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks but the other one is a little shorter
    NXSupport - Your one-stop source for computer help

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