Animasi Flash Jam Analog di atas, visual tampilannya akan serupa dengan aplikasi Jam Analog VB 6.0, dari Aplikasi VB 6.0 tersebut akan dikonvert ke aplikasi VB 2008 Express Edition. Pada awalnya Saya kebingungan bagaimana mengkonvertnya, akhirnya dengan sedikit kesabaran dengan meninggikan asas Try and Error akhirnya dapat terpecahkan. Tampilan Jam Analog dengan VB 6.0. Perhatikan gambar di bawah ini.
Script VB 6.0 Jam Analog sebagai berikut:
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
' Convert Jam Analog VB 6.0 to VB 2008 Express Edition '
'======================================================================='
' '
' Berbagi ilmu Sensasi Kepuasan Tersendiri '
' Sourcecode:====>>>> www.thaiio.com'
' Publish to V. Hutabalian's Blog 16 July 2010 '
'+++++++++++++++++++++++========================++++++++++++++++++++++++'
Dim midX As String
Dim midY As String
Dim HourLength As Integer
Dim MinLength As Integer
Dim secondLength As Integer
Const PI = 3.1459
Private Sub Form_Resize()
Me.Cls
Form1.BackColor = vbBlack
Form1.ForeColor = vbWhite
Line1.BorderColor = QBColor(10)
Line2.BorderColor = QBColor(11)
Line3.BorderColor = QBColor(12)
Line1.BorderWidth = 4
Line2.BorderWidth = 3
Line3.BorderWidth = 1
midX = Me.ScaleWidth / 2
midY = Me.ScaleHeight / 2
Line1.X1 = midX
Line1.Y1 = midY
Line2.X1 = midX
Line2.Y1 = midY
Line3.X1 = midX
Line3.Y1 = midY
If Me.ScaleHeight < Me.ScaleWidth Then
HourLength = (Me.ScaleHeight / 2) * (50 / 100)
MinLength = (Me.ScaleHeight / 2) * (75 / 100)
secondLength = (Me.ScaleHeight / 2) * (85 / 100)
Length = (Me.ScaleHeight / 2) * (85 / 100)
Else
HourLength = (Me.ScaleWidth / 2) * (50 / 100)
MinLength = (Me.ScaleWidth / 2) * (75 / 100)
secondLength = (Me.ScaleWidth / 2) * (85 / 100)
Length = (Me.ScaleWidth / 2) * (85 / 100)
End If
For I = 1 To 12 Step 1
HourX = Length * Cos(PI * (30 * I - 90) / 180) + midX
HourY = Length * Sin(PI * (30 * I - 90) / 180) + midY
Me.CurrentX = HourX
Me.CurrentY = HourY
Print I
Next I
End Sub
Private Sub Timer1_Timer()
Me.Caption = Time$
Hours = Hour(Time)
minutes = Minute(Time)
seconds = Second(Time)
TrueHours = Hours + minutes / 60
Line1.X2 = HourLength * Cos(PI * (30 * TrueHours - 90) / 180) + midX
Line1.Y2 = HourLength * Sin(PI * (30 * TrueHours - 90) / 180) + midY
Line2.X2 = MinLength * Cos(PI * (6 * minutes - 90) / 180) + midX
Line2.Y2 = MinLength * Sin(PI * (6 * minutes - 90) / 180) + midY
Line3.X2 = secondLength * Cos(PI * (6 * seconds - 90) / 180) + midX
Line3.Y2 = secondLength * Sin(PI * (6 * seconds - 90) / 180) + midY
End Sub
Script Jam Analog VB 6.0 di atas akan kita konvert ke VB 2008 Express Edition. Perhatikan langkah-langkahnya, Hasil tampilannya lihat gambar di bawah ini:
Toolbox yang akan kita pergunakan perhatikan tabel di bawah ini:
1 UserForm | Name: UserForm1 Text: V. Hutabalian's Blog Jam Analog" |
3 LineShape | Name:LineShape1-3 |
Desain Form table Toolbox di atas perhatikan gambar di bawah ini:
Setelah selesai mendesai Form dengan mengatur semua object propertis Toolbox. Ketikkan source program di bawah ini dengan mengarahkan kursor pada design Form, Klik kanan lalu pilih View Code.
Script Program Jam Analog VB 2008 Express Edition:
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
' Convert Jam Analog VB 6.0 to VB 2008 Express Edition '
'======================================================================='
' '
' Berbagi ilmu Sensasi Kepuasan Tersendiri '
' Modifikasi script Programing By: Verynandus Hutabalian'
' Publish to V. Hutabalian's Blog 16 July 2010 '
'+++++++++++++++++++++++========================++++++++++++++++++++++++'
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Drawing2D
Imports System.Math
Public Class Form1
Inherits System.Windows.Forms.Form
Dim midX As Single
Dim midY As Single
Dim HourX As Single
Dim HourY As Single
Dim HourLength As Integer
Dim MinLength As Integer
Dim secondLength As Integer
Dim Length As Single
Const PI = 3.1459
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim newfont As Font = New Font("Arial", 10)
Dim g As Graphics = Graphics.FromHwnd(Me.Handle)
Me.BackColor = Color.Black
Me.ForeColor = Color.White
LineShape1.BorderColor = Color.Blue
LineShape2.BorderColor = Color.Green
LineShape3.BorderColor = Color.Red
LineShape1.BorderWidth = 4
LineShape2.BorderWidth = 3
LineShape3.BorderWidth = 2
midX = Me.ClientSize.Width / 2
midY = Me.ClientSize.Height / 2
LineShape1.X1 = midX
LineShape1.Y1 = midY
LineShape2.X1 = midX
LineShape2.Y1 = midY
LineShape3.X1 = midX
LineShape3.Y1 = midY
If Me.ClientSize.Height < Me.ClientSize.Width Then
HourLength = (Me.ClientSize.Height / 2) * (50 / 100)
MinLength = (Me.ClientSize.Height / 2) * (75 / 100)
secondLength = (Me.ClientSize.Height / 2) * (85 / 100)
Length = (Me.ClientSize.Height / 2) * (85 / 100)
Else
HourLength = (Me.ClientSize.Width / 2) * (50 / 100)
MinLength = (Me.ClientSize.Width / 2) * (75 / 100)
secondLength = (Me.ClientSize.Width / 2) * (85 / 100)
Length = (Me.ClientSize.Width / 2) * (85 / 100)
End If
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim ValueFont As New Font("Arial", 12, FontStyle.Regular)
Dim I As Single
For I = 1 To 12 Step 1
HourX = Length * Cos(PI * (30 * I - 90) / 180) + midX
HourY = Length * Sin(PI * (30 * I - 90) / 180) + midY
Me.CreateParams.X = HourX
Me.CreateParams.Y = HourY
Me.CreateGraphics.DrawString(I.ToString, ValueFont, Brushes.GreenYellow, HourX, HourY)
Me.CreateGraphics.DrawString("V. Hutabalian's Blog Jam Analog VB 6.0", ValueFont, Brushes.Tomato, 70, 135)
Me.CreateGraphics.DrawString("Convert" & " " & " to", ValueFont, Brushes.Cyan, 155, 173)
Me.CreateGraphics.DrawString("VB 2008 Express Edition", ValueFont, Brushes.Gold, 135, 211)
Next I
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.Refresh()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Hours As Integer
Dim minutes As Integer
Dim Seconds As Integer
Dim TrueHours As Integer
Me.Text = TimeOfDay
Hours = Hour(TimeOfDay)
minutes = Minute(TimeOfDay)
Seconds = Second(TimeOfDay)
TrueHours = Hours + minutes / 60
LineShape1.X2 = HourLength * Cos(PI * (30 * TrueHours - 90) / 180) + midX
LineShape1.Y2 = HourLength * Sin(PI * (30 * TrueHours - 90) / 180) + midY
LineShape2.X2 = MinLength * Cos(PI * (6 * minutes - 90) / 180) + midX
LineShape2.Y2 = MinLength * Sin(PI * (6 * minutes - 90) / 180) + midY
LineShape3.X2 = secondLength * Cos(PI * (6 * Seconds - 90) / 180) + midX
LineShape3.Y2 = secondLength * Sin(PI * (6 * Seconds - 90) / 180) + midY
End Sub
End Class
Setelah Anda mengetikkan listing source program diatas tekan F5, maka hasil tampilan visualnya seperti gambar di bawah ini.
Selamat mencoba Guys! Nantikan Tips Aplikasi Cantik Lainnya by Verynandus Hutabalian.
0 komentar:
Posting Komentar