Jam atau watch merupakan Alat untuk menunjukkan Waktu. Di Vb 2010 kita dapat membuat Jam analog ataupun jam Digital.
Private Sub InitializeComponent()
Berikut Source code untuk Jam Analog:
Public Class FrmTest
Inherits System.Windows.Forms.Form
Dim WithEvents OptionMenu As System.Windows.Forms.ContextMenu
Dim WithEvents Digital As System.Windows.Forms.MenuItem
Dim WithEvents ShwHdBackground As System.Windows.Forms.MenuItem
Friend WithEvents TungDigitalWatch1 As DigitalWatch.tungDigitalWatch
Dim msdown As Boolean
Dim x, y As Integer
Friend WithEvents lblAmPm As System.Windows.Forms.Label
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Friend WithEvents timerAmPm As System.Windows.Forms.Timer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Me.components = New System.ComponentModel.Container()
Me.timerAmPm = New System.Windows.Forms.Timer(Me.components)
Me.lblAmPm = New System.Windows.Forms.Label()
Me.TungDigitalWatch1 = New DigitalWatch.tungDigitalWatch()
Me.SuspendLayout()
'
'timerAmPm
'
'
'lblAmPm
'
Me.lblAmPm.Font = New System.Drawing.Font("Gill Sans Ultra Bold", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblAmPm.Location = New System.Drawing.Point(138, 12)
Me.lblAmPm.Name = "lblAmPm"
Me.lblAmPm.Size = New System.Drawing.Size(40, 28)
Me.lblAmPm.TabIndex = 1
Me.lblAmPm.Text = "--"
Me.lblAmPm.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TungDigitalWatch1
'
Me.TungDigitalWatch1.AllowDrop = True
Me.TungDigitalWatch1.BackColor = System.Drawing.Color.Black
Me.TungDigitalWatch1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TungDigitalWatch1.Location = New System.Drawing.Point(12, 12)
Me.TungDigitalWatch1.Name = "TungDigitalWatch1"
Me.TungDigitalWatch1.Size = New System.Drawing.Size(120, 28)
Me.TungDigitalWatch1.TabIndex = 0
Me.TungDigitalWatch1.Watch_Alarm = False
Me.TungDigitalWatch1.Watch_AlarmTime = New Date(2003, 11, 24, 14, 52, 30, 0)
Me.TungDigitalWatch1.Watch_ChangeColor = True
Me.TungDigitalWatch1.Watch_ForeColor = DigitalWatch.tungDigitalWatch.ClockForeColor.Red
Me.TungDigitalWatch1.Watch_Size = 1
'
'FrmTest
'
Me.AllowDrop = True
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(183, 62)
Me.Controls.Add(Me.lblAmPm)
Me.Controls.Add(Me.TungDigitalWatch1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "FrmTest"
Me.Text = "Membuat Jam Digital"
Me.TopMost = True
Me.ResumeLayout(False)
End Sub
#End Region
'Added By Steven last
Private Sub timerAmPm_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerAmPm.Tick
Dim Time As String = CStr(TimeOfDay)
Dim chkTime As String
'Checks the time to see if it is AM or PM
chkTime = Time.Substring(0, 2)
'Checks if the Hour is either 10,11,12 if so Substring numbers have to be different
If chkTime = "10" Or chkTime = "11" Or chkTime = "12" Then
lblAmPm.Text = Time.Substring(0, 2)
Else
lblAmPm.Text = Time.Substring(8, 2)
End If
End Sub
Private Sub TungDigitalWatch1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles TungDigitalWatch1.Load
timerAmPm.Start()
End Sub
'Added By Steven last
Private Sub FrmTest_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
BackColor = Color.Black
'Sets up the Context Menu for the program
With Me
OptionMenu = New System.Windows.Forms.ContextMenu
.Digital = New System.Windows.Forms.MenuItem
.ShwHdBackground = New System.Windows.Forms.MenuItem
.OptionMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.Digital, .ShwHdBackground})
.ShowInTaskbar = False
.ContextMenu = OptionMenu
End With
With TungDigitalWatch1
.ContextMenu = OptionMenu
End With
With lblAmPm
.ContextMenu = OptionMenu
End With
With Digital
.Index = 0
.Text = "Analog"
End With
With ShwHdBackground
.Index = 1
.Text = "Exit"
End With
End Sub
'Added By Steven last
Private Sub ShwHdBackground_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShwHdBackground.Click
'exits the program
Me.Close()
frmAnalog.Close()
End Sub
'Added By Steven last
Private Sub Digital_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Digital.Click
'Hides Digital Clock
Me.Hide()
'Shows Analog Clock
frmAnalog.Show()
End Sub
End Class
Untuk lebih jelasnya dapat di download disini