Membuat Aplikasi Jam Analog - Visual Basic 6.

0
Kali ini kita akan membahas cara membuat 'Jam Analog' yang dibuat dengan menggunan Microsoft Visual Basic 6.0. Langsung saja, pertama kali yang harus anda lakukan adalah membuka aplikasi 'Microsoft Visual Basic 6.0'. Pastikan Visual Basic telah terinstal di komputer anda. Atau bila anda ingin yang lebih mudah, download Visual Basic 6.0 versi Portable. (cari di google dengan menggunakan kata kunci 'Visual Basic 6.0 portable', tanpa tanda kutip). Langkah - langkah pembuatan jam analog adalah sebagai berikut : 1. Ubah Properti 'Name' Form1 menjadi 'frmMain', BackColor = black, BorderStyle = 0, DrawWidth = 3, ForeColor = White, Height = 3075,MaxButton = False, MinButton = False, StartUpPosition = 2, Width = 2625. 2. Kemuadian gambar 3 buah jarum jam dengan menggunakan Line Tool (Detik, Menit, Jam) dengan catatan, ketiga line tersebut berada mempunyai titik pusat yang sma. Ganti Properti 'Name'nya menjadi (Linehour,lineMinute,lineSecond) 3. Buat sebuah Label di bawah ketiga jarum jam tadi, ganti Properti 'Name'nya menjadi Lbltime 4. Masukkan sebuah objek 'Timer',ganti Properti 'Name'nya menjadi tmrClock dan atur Properti 'Intervalnya' = 1 5. Setelah semua objek telah dimasukkan di Design View, lalu klik menu 'View + Code' kemudian copy paste kode di bawah ini. Source kode untuk aplikasi Jam Analog : Option Explicit Private Const pi As Double = 3.14159265358979 Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Private Sub MakeRoundObject(objObject As Object, Value As Long) Static lngHeight, lngLong, lngReturn, lngWidth As Long lngWidth = objObject.Width / Screen.TwipsPerPixelX lngHeight = objObject.Height / Screen.TwipsPerPixelY

Value). dblHour As Double dblSecond = Second(Now) * 6 . 2. Shift As Integer. 0. 1100 * Sin(intX * pi / 180) + lineSecond.DrawWidth = 3 Me. CreateRoundRectRgn(0.Y1) Else Me.PSet (1100 * Cos(intX * pi / 180) + lineSecond. X As Single.Y1) End If Next intX End Sub Private Sub Form_MouseDown(Button As Integer. &HA1. lngHeight. 0& End Sub Private Sub lblTime_MouseDown(Button As Integer. Y) End Sub Private Sub tmrClock_Timer() Dim dblSecond As Double. X As Single. Y As Single) ReleaseCapture SendMessage Me. X.X1. Shift.hWnd.PSet (1100 * Cos(intX * pi / 180) + lineSecond.X1.DrawWidth = 6 Me. Value.90 . Shift As Integer) If KeyCode = vbKeyEscape Then App.hWnd. 20) Call tmrClock_Timer For intX = 0 To 360 Step 6 If intX Mod 30 = 0 Then Me. lngWidth. dblMinute As Double. Y As Single) Call Form_MouseDown(Button. 1100 * Sin(intX * pi / 180) + lineSecond. Shift As Integer.SetWindowRgn objObject. True End Sub Private Sub Form_KeyDown(KeyCode As Integer.TaskVisible = False Unload Me End End If End Sub Private Sub Form_Load() Dim intX As Integer Call MakeRoundObject(frmMain.

Y1 lineHour.dblMinute = (Minute(Now) + Second(Now) / 60) * 6 . "hh:mm:ss") End Sub Setelah selesai.Y2 = 1000 * Sin(dblSecond * pi / 180) + lineSecond.kira seperti ini : Selamat Mencoba.Caption = Format(Now.Y1 lineMinute.Y1 lblTime.X2 = 900 * Cos(dblMinute * pi / 180) + lineMinute.Y2 = 700 * Sin(dblHour * pi / 180) + lineHour.X1 lineHour.Y2 = 900 * Sin(dblMinute * pi / 180) + lineMinute.90 lineSecond.X1 lineMinute.. ketika anda klik tombol 'Start'.90 dblHour = (Hour(Now) + Minute(Now) / 60) * 30 . :) .X1 lineSecond. maka akan muncul hasil dari 'Aplikasi Jam Analog' kira .X2 = 700 * Cos(dblHour * pi / 180) + lineHour..X2 = 1000 * Cos(dblSecond * pi / 180) + lineSecond.