Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to incorporate a Timer Control in MS VB 2K5 Express

Status
Not open for further replies.

VoodooRageII

Programmer
Aug 25, 2002
14
0
0
US
Hi all, I have a program that I am doing to help a friend copy files without having to do it manually, in VB 2K5 Express that I need to incorporate a timer but have not had any luck as I am not very familiar with this control. I think what I need is fairly simple. I have a button on a form that would activate the timer that would count down updating a text box for the 20 second count down. At zero a function is called to copy the contents of a directory. When the copy is finished the timer would be reset to 20 and the process reinitiated. I would greatly appreciate any insight on how to use the timer to do this as I am not very familiar with the use of this control.

Thanks, your help is very much appreciated.
 
Here is a simple code
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Timer1.Start()
        Me.Label1.Text = "20"
        Me.Timer1.Interval = 1000
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Not Me.Label1.Text = CInt(0) Then
            Me.Label1.Text = CInt(Me.Label1.Text) - 1
        Else
            'Do your copy work here
            'Also you can restart timer here
        End If
    End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top