Mengukur Kecepatan (Test Speed) Form dengan Visual Basic 6.0 - Form Visual Basic yang Anda sering gunakan ternyata bisa di ukur kecepatannya dengan menggunakan motode Function GetTickCount, dengan hanya menekan satu tombol saja kecepatan form Anda sudah bisa diketahui.
Buat Anda yang ingin mengetahui bagaimana cara membuat Test Speed Form mari kita simak langkah-langkah berikut dibawah ini:
Mengukur Kecepatan (Test Speed) Form dengan Visual Basic 6.0
1. Masuk ke Form VB 6 Anda
2. Tambahkan 1 CommandButton dan 1 Label
3. Kemudian Anda ketik kode dibawah ini :
Option Explicit
'form speed
Private Declare Function GetTickCount Lib "kernel32" () As Long
'form semi transparant
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal color As Long, ByVal x As Byte, ByVal alpha As Long) As Boolean
Const LWA_BOTH = 3
Const LWA_ALPHA = 2
Const LWA_COLORKEY = 1
Const GWL_EXSTYLE = -20
Const WS_EX_LAYERED = &H80000
Dim iTransparant As Integer
'form semi transparant
Sub MakeTransparan(hWndBro As Long, iTransp As Integer)
On Error Resume Next
Dim ret As Long
ret = GetWindowLong(hWndBro, GWL_EXSTYLE)
SetWindowLong hWndBro, GWL_EXSTYLE, ret Or WS_EX_LAYERED
SetLayeredWindowAttributes hWndBro, RGB(255, 255, 0), iTransp, LWA_ALPHA
Exit Sub
End Sub
'form speed
Public Function FormTestSpeed(frm As Form) As Long
Dim lSpeedTime As Long
Dim SInfoSpeed As String
lSpeedTime = GetTickCount
Unload frm
Load frm
frm.Show
lSpeedTime = GetTickCount - lSpeedTime
' this is only simulation
If lSpeedTime <= 50 Then
SInfoSpeed = "[Very Fast]"
ElseIf lSpeedTime >= 50 And lSpeedTime <= 100 Then
SInfoSpeed = "[Normal]"
ElseIf lSpeedTime >= 100 And lSpeedTime <= 200 Then
SInfoSpeed = "[Slow]"
ElseIf lSpeedTime >= 200 Then
SInfoSpeed = "[Very Slow]"
End If
Label1.Caption = "Time Speed Form: " & lSpeedTime & " Milliseconds - " & SInfoSpeed
End Function
Private Sub command1_Click()
'form Speed
FormTestSpeed Form11
End Sub
Private Sub Form_Load()
'semi transparant
On Error Resume Next
MakeTransparan Me.hWnd, 75
End Sub
4. Simpan kode Anda dan jalankan program.klik Tombol untuk mengukur kecepatan
Catatan :
- Kata "Form11" yang berada di kode di atas yang bercetak tebal sesuaikan dengan form Anda
- Form hasil sengaja Saya buat Transfarant
Hasil Pengukuran kecepatan Form |
Demikian tip Mengukur Kecepatan (Test Speed) Form dengan Visual Basic 6.0. Selamat mencoba semoga berhasil.
No comments:
Post a Comment