Results 1 to 3 of 3

Thread: Creating objects at runtime?

  1. #1

    Thread Starter
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    What would be the easiest way to create command buttons based apon stored settings. Say you want to make a cusomiseable shortcut bar, but you want the user to be able to specify as many buttons linked to any exe. i know how to do everything except make the command buttons at runtime. Any suggestions?

  2. #2
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    Straight from MSDN

    Code:
    Option Explicit
    Private WithEvents btnObj As CommandButton
    
    Private Sub btnObj_Click()
       MsgBox "This is a dynamically added button."
    End Sub
    
    Private Sub Form_Load()
       Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
       With btnObj
          .Visible = True
          .Width = 2000
          .Caption = "Hello"
          .Top = 1000
          .Left = 1000
       End With
    End Sub
    Regards,
    TheBao

  3. #3

    Thread Starter
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550

    Cool

    Thanx man that is exactly what i was looking for.

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