Results 1 to 2 of 2

Thread: [RESOLVED] Declaring components without drawing on form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Resolved [RESOLVED] Declaring components without drawing on form

    VB Code:
    1. Option Explicit
    2.  
    3. Private WithEvents TCalculateBandwidth As Timer
    4.  
    5. Private Sub Form_Load()
    6.     Me.Move 0, 0
    7.     With TCalculateBandwidth
    8.         .Interval = 1000
    9.         .Enabled = True
    10.     End With
    11. End Sub
    12.  
    13. Private Sub TCalculateBandwidth_Timer()
    14.     MsgBox "yay"
    15.     End
    16. End Sub
    I have a felling I am missing a Set in the Form_Load but when I type out "Set TCalculateBandwidth =" a true false select box comes up. :s

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Declaring components without drawing on form

    If you want to create controls at runtime use the Controls.Add method

    VB Code:
    1. Private WithEvents TCalculateBandwidth As VB.Timer
    2.  
    3. Private Sub Form_Load()
    4.     Me.Move 0, 0
    5.     Set TCalculateBandwidth = Controls.Add("VB.Timer", "Timer1")
    6.     With TCalculateBandwidth
    7.         .Interval = 1000
    8.         .Enabled = True
    9.     End With
    10. End Sub
    11.  
    12. Private Sub TCalculateBandwidth_Timer()
    13.     MsgBox "yay"
    14.     TCalculateBandwidth.Enabled = False
    15.     Unload Me
    16. End Sub

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