Results 1 to 4 of 4

Thread: creating new instances

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    72
    how do you create a new instance of a control that is already on a form.


    I have a control on a form and need to make a few of them but don't know how many i will need to until form is built.

    thanks

    VB 6 Professional Edition

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Give the first control (already on the form) an index of 0, which will tell VB to use it as a control array. Then, just use the Load command to make a new one:
    Code:
    Load Text1(1)
    Text1(1).Visible = True
    Although the new control will be in exactly the same place as the original, so you'd need to move it using code.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    Don't forget to move it once you create it.
    Code:
    Load Picture1(1)
    Picture1(1).Move 0, 0
    Picture1(1).Visible = True

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    'load an array of controls at runtime
    'add 3 controls and line them up
    'as above create the array and leave only one
    'control on the form index(0)

    [code]
    Private Sub Command1_Click(Index As Integer)

    Dim intcre As Integer

    Do Until intcre = 3
    intcre = intcre + 1
    Load Command1(intcre)
    Command1(intcre).Left = Command1(intcre - 1).Left + Command1(intcre).Width
    Command1(intcre).Top = Command1(intcre - 1).Top
    Command1(intcre).Visible = True

    Loop

    End Sub
    [/code}
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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