Results 1 to 6 of 6

Thread: I don't know how to call it

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Ok here is the problem. I have a label on my form and I want to create a new one with exactly the same properties with code. I know that it is simple but I have very hard time doing it. Thanks for any help.
    Regards QWERTY

  2. #2
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    uh,

    Sounds WAY to easy.
    Just Make an Array of the control object that you want and that should have the same code.
    Whats wrong with that idea??

  3. #3
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    here's how:

    Code:
    Static NewIdx as integer
    
    Sub LoadLabel
    
    NewIdx = NewIdx + 1
    Load Label1(NewIdx)
    
    end sub
    make sure the first Label1's Index property is set to 0 at design time.
    so when u create a new Label1, it increases NewIdx, and loads a new label with the same properties.


    ------------------
    cintel rules
    www.cintelsoftware.co.uk

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Controls created via the Load command are invisible when created, so you'll need to set their Visible property to true. You'll also need to move them some place since they will be drawn on top of the original control.

    ------------------
    Marty

  5. #5
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    In case anyone cares, you can add a control at run time without a control array:

    Code:
        Dim ctl As Label
        
        Set ctl = Form1.Controls.Add("VB.Label", "lblNewLabel", Form1)
        
        With ctl
            .Visible = True
            .Top = 200
            .Left = 10
            .Caption = "Hello World!"
        End With

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Thanks!!!!

    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


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