Timer event : Timer « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » Timer 
14.90.3.Timer event
Timer event
Imports System.Windows.Forms

public class TimerEvent
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New()

        InitializeComponent()

    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    Private components As System.ComponentModel.IContainer

    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(1624)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(11224)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Systen Date"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(1680)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(11224)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "System Time"
        '
        'Timer1
        '
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(11216)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(10420)
        Me.TextBox1.TabIndex = 2
        Me.TextBox1.Text = ""
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(11272)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(10420)
        Me.TextBox2.TabIndex = 3
        Me.TextBox2.Text = ""
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(292158)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Timer1.Tick
        Dim TDay As String
        Dim As Short
        TextBox2.Text = CStr(TimeOfDay)
        i = Weekday(Today)
        Select Case i
            Case 1
                TDay = "Sunday"
            Case 2
                TDay = "Monday"
            Case 3
                TDay = "Tuesday"
            Case 4
                TDay = "Wednesday"
            Case 5
                TDay = "Thursday"
            Case 6
                TDay = "Friday"
            Case 7
                TDay = "Saturday"
        End Select
        TextBox1.Text = TDay & "," & Today
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgsHandles MyBase.Load
        Me.Timer1.Start()
    End Sub
End Class
14.90.Timer
14.90.1.Timer intervalTimer interval
14.90.2.Use Timer to refresh LabelUse Timer to refresh Label
14.90.3.Timer eventTimer event
14.90.4.Timer Start and StopTimer Start and Stop
14.90.5.Scrolling Text by TimerScrolling Text by Timer
14.90.6.Use three timersUse three timers
14.90.7.Set up an event handler for the Timer.Elapsed event, creates a timer, and starts the timer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.