Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 131,706 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,424 people online right now. Registration is fast and FREE... Join Now!




Using Handlers

 
Reply to this topicStart new topic

Using Handlers, buttons generated at runtime

shosoc00
post 14 Feb, 2005 - 12:37 PM
Post #1


New D.I.C Head

*
Joined: 2 Feb, 2005
Posts: 5

hi
my goal is to be able to create a button at runtime and have that button start and stop a timer, but i cant get this Handles thing figured out. i was wondering what the handler function looks like.

any help is appreciated thanx!
User is offlineProfile CardPM

Go to the top of the page

zakary
post 15 Feb, 2005 - 07:41 AM
Post #2


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 400



Thanked 6 times

Dream Kudos: 175
My Contributions


try this
Private Sub cmdStart_Click()

On Error GoTo errorHandler
If (startStop = False) Then
'do something
ElseIf (startStop = True) Then
'do something
End If
User is offlineProfile CardPM

Go to the top of the page

BlackJesus
post 16 Feb, 2005 - 10:28 PM
Post #3


D.I.C Head

Group Icon
Joined: 10 Feb, 2005
Posts: 161



Thanked 1 times

Dream Kudos: 175
My Contributions


you just want a button to be created at runtime? or you want it to be created AND do something( automatically, or clicked on?)...>_<
User is offlineProfile CardPM

Go to the top of the page

tel0r
post 22 Feb, 2005 - 03:00 PM
Post #4


New D.I.C Head

Group Icon
Joined: 22 Feb, 2005
Posts: 27



Dream Kudos: 200
My Contributions


CODE

'General Declarations
'use WithEvents to invoke the _Click event etc
Dim WithEvents Cmd As CommandButton

'Form
Private Sub Form_Load()
Set Cmd = Controls.Add("VB.CommandButton", "Cmd")
'Cmd.Move left,[top],[width],[height]
Cmd.Visible = True
Cmd.Caption = "Start"
End Sub

Private Sub Cmd_Click()
If Timer1 = False Then
   Cmd.Caption = "Stop"
   Timer1 = True
Else
   Cmd.Caption = "Start"
   Timer1 = False
End If
End Sub

Private Sub Timer1_Timer()
Debug.Print Timer
End Sub
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 09:22AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month