Results 1 to 4 of 4

Thread: How to create a control array?

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    38

    Question

    I would like to create an array of labels. I would like to link these labels to an external data source. I believe the best way is to create a control array. How can I do this?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    change this to labels.
    Code:
    'add an option button to your form
    'right click it and copy and then add
    'you will be asked if you want an array..say yes
    'delete the button you just added
    'leaving the option button with index = 0 on the form
    
    Option Explicit
    
    Public MaxId As Integer
    
    Private Sub option1_Click(Index As Integer)
      Option1(0).Caption = "This is as good as it gets."
    End Sub
    
    Private Sub command1_Click()
    
    MaxId = 4
       Dim i
       For i = 1 To MaxId
       Load Option1(i)     ' Create new button.
       Option1(0).SetFocus      ' Reset button selection.
       ' Set new button under previous button.
       Option1(i).Top = Option1(i - 1).Top + 400
       Option1(i).Visible = True  ' Display new
                                     ' button.
       Option1(i).Width = 4000
       Option1(i).Caption = "Option" & i + 1
       Next i
    End Sub
    
    'Option buttons are removed by the Click event procedure for the Delete command button:
    
    Private Sub Command2_Click()
     For i = 1 To MaxId
       If MaxId < 1 Then Exit Sub   ' Keep first buttons.
       Unload Option1(i)          ' Delete last button.
       MaxId = MaxId - 1            ' Decrement button count.
       Option1(0).SetFocus       ' Reset button selection.
       Option1(0).Width = 4000
    
    Next
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    38
    Thank you. Solved my problem. You're excellent dudes.

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