Download contoh game
APLIKASI GAME 10 DETIK
APLIKASI GAME 10 DETIK
Option Explicit
' Declare countdown variables for each button. These will begin at 10
' and countdown by one with each buttons timer event.
Dim fiCount1 As Integer
Dim fiCount2 As Integer
Dim fiCount3 As Integer
Dim fiCount4 As Integer
Dim fiCount5 As Integer
Dim fiCount6 As Integer
Dim fiCount7 As Integer
Dim fiCount8 As Integer
Dim fiCount9 As Integer
'Declare countdown speed variables for each button. Each button will have its
'own random countdown speed which will decrease when the button is clicked.
Dim fiSpeed1 As Integer
Dim fiSpeed2 As Integer
Dim fiSpeed3 As Integer
Dim fiSpeed4 As Integer
Dim fiSpeed5 As Integer
Dim fiSpeed6 As Integer
Dim fiSpeed7 As Integer
Dim fiSpeed8 As Integer
Dim fiSpeed9 As Integer
'Declare variable for game score
Dim fiScore As Integer
Dim fiNumLeft As Integer
'Declare variable to check that same button has not been pressed twice so as to
'disable cheating by just clicking repeatedly on the button.
Dim fiLastPressed As Integer
Private Sub cmd1_Click()
If fiLastPressed <> 1 Then
fiCount1 = 10
cmd1.Caption = 10
Timer1.Interval = Timer1.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 1
End If
End Sub
Private Sub cmd2_Click()
If fiLastPressed <> 2 Then
fiCount2 = 10
cmd2.Caption = 10
Timer2.Interval = Timer2.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 2
End If
End Sub
Private Sub cmd3_Click()
If fiLastPressed <> 3 Then
fiCount3 = 10
cmd3.Caption = 10
Timer3.Interval = Timer3.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 3
End If
End Sub
Private Sub cmd4_Click()
If fiLastPressed <> 4 Then
fiCount4 = 10
cmd4.Caption = 10
Timer4.Interval = Timer4.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 4
End If
End Sub
Private Sub cmd5_Click()
If fiLastPressed <> 5 Then
fiCount5 = 10
cmd5.Caption = 10
Timer5.Interval = Timer5.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 5
End If
End Sub
Private Sub cmd6_Click()
If fiLastPressed <> 6 Then
fiCount6 = 10
cmd6.Caption = 10
Timer6.Interval = Timer6.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 6
End If
End Sub
Private Sub cmd7_Click()
If fiLastPressed <> 7 Then
fiCount7 = 10
cmd7.Caption = 10
Timer7.Interval = Timer7.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 7
End If
End Sub
Private Sub cmd8_Click()
If fiLastPressed <> 8 Then
fiCount8 = 10
cmd8.Caption = 10
Timer8.Interval = Timer8.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 8
End If
End Sub
Private Sub cmd9_Click()
If fiLastPressed <> 9 Then
fiCount9 = 10
cmd9.Caption = 10
Timer9.Interval = Timer9.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 9
End If
End Sub
Private Sub cmdQuit_Click()
End
End Sub
Private Sub cmdStart_Click()
cmd1.Enabled = True
cmd2.Enabled = True
cmd3.Enabled = True
cmd4.Enabled = True
cmd5.Enabled = True
cmd6.Enabled = True
cmd7.Enabled = True
cmd8.Enabled = True
cmd9.Enabled = True
fiCount1 = 11
fiCount2 = 11
fiCount3 = 11
fiCount4 = 11
fiCount5 = 11
fiCount6 = 11
fiCount7 = 11
fiCount8 = 11
fiCount9 = 11
fiScore = 0
TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 8
'set initial start speeds for each timer
Timer1.Interval = 1000
Timer2.Interval = 1000
Timer3.Interval = 1000
Timer4.Interval = 1000
Timer5.Interval = 1000
Timer6.Interval = 1000
Timer7.Interval = 1000
Timer8.Interval = 1000
Timer9.Interval = 1000
'Start all timers counting down
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Timer4.Enabled = True
Timer5.Enabled = True
Timer6.Enabled = True
Timer7.Enabled = True
Timer8.Enabled = True
Timer9.Enabled = True
tmrEndGame.Enabled = True
End Sub
Private Sub Command1_Click()
frmAbout.Show
End Sub
Private Sub Form_Load()
fiCount1 = 10
fiCount2 = 10
fiCount3 = 10
fiCount4 = 10
fiCount5 = 10
fiCount6 = 10
fiCount7 = 10
fiCount8 = 10
fiCount9 = 10
fiScore = 0
TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 8
'set initial start speeds for each timer
Timer1.Interval = 1000
Timer2.Interval = 1000
Timer3.Interval = 1000
Timer4.Interval = 1000
Timer5.Interval = 1000
Timer6.Interval = 1000
Timer7.Interval = 1000
Timer8.Interval = 1000
Timer9.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If fiCount1 = 0 Then
Timer1.Enabled = False
cmd1.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount1 = fiCount1 - 1
cmd1.Caption = Str(fiCount1)
End If
End Sub
Private Sub Timer2_Timer()
If fiCount2 = 0 Then
Timer2.Enabled = False
cmd2.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount2 = fiCount2 - 1
cmd2.Caption = Str(fiCount2)
End If
End Sub
Private Sub Timer3_Timer()
If fiCount3 = 0 Then
Timer3.Enabled = False
cmd3.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount3 = fiCount3 - 1
cmd3.Caption = Str(fiCount3)
End If
End Sub
Private Sub Timer4_Timer()
If fiCount4 = 0 Then
Timer4.Enabled = False
cmd4.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount4 = fiCount4 - 1
cmd4.Caption = Str(fiCount4)
End If
End Sub
Private Sub Timer5_Timer()
If fiCount5 = 0 Then
Timer5.Enabled = False
cmd5.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount5 = fiCount5 - 1
cmd5.Caption = Str(fiCount5)
End If
End Sub
Private Sub Timer6_Timer()
If fiCount6 = 0 Then
Timer6.Enabled = False
cmd6.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount6 = fiCount6 - 1
cmd6.Caption = Str(fiCount6)
End If
End Sub
Private Sub Timer7_Timer()
If fiCount7 = 0 Then
Timer7.Enabled = False
cmd7.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount7 = fiCount7 - 1
cmd7.Caption = Str(fiCount7)
End If
End Sub
Private Sub Timer8_Timer()
If fiCount8 = 0 Then
Timer8.Enabled = False
cmd8.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount8 = fiCount8 - 1
cmd8.Caption = Str(fiCount8)
End If
End Sub
Private Sub Timer9_Timer()
If fiCount9 = 0 Then
Timer9.Enabled = False
cmd9.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount9 = fiCount9 - 1
cmd9.Caption = Str(fiCount9)
End If
End Sub
Private Sub tmrEndGame_Timer()
If fiNumLeft = 0 Then
cmd1.Caption = "X"
cmd2.Caption = "X"
cmd3.Caption = "X"
cmd4.Caption = "X"
cmd5.Caption = "X"
cmd6.Caption = "X"
cmd7.Caption = "X"
cmd8.Caption = "X"
cmd9.Caption = "X"
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = False
Timer6.Enabled = False
Timer7.Enabled = False
Timer8.Enabled = False
Timer9.Enabled = False
frmGameOver.Visible = True
tmrEndGame.Enabled = False
End If
End Sub
frmAbout :
Option Explicit
' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
' Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_DWORD = 4 ' 32-bit number
Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
Const gREGVALSYSINFOLOC = "MSINFO"
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
Const gREGVALSYSINFO = "PATH"
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Sub cmdSysInfo_Click()
Call StartSysInfo
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Public Sub StartSysInfo()
On Error GoTo SysInfoErr
Dim rc As Long
Dim SysInfoPath As String
' Try To Get System Info Program Path\Name From Registry...
If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
' Try To Get System Info Program Path Only From Registry...
ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
' Validate Existance Of Known 32 Bit File Version
If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
' Error - File Can Not Be Found...
Else
GoTo SysInfoErr
End If
' Error - Registry Entry Can Not Be Found...
Else
GoTo SysInfoErr
End If
Call Shell(SysInfoPath, vbNormalFocus)
Exit Sub
SysInfoErr:
MsgBox "System Information Is Unavailable At This Time", vbOKOnly
End Sub
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
Dim i As Long ' Loop Counter
Dim rc As Long ' Return Code
Dim hKey As Long ' Handle To An Open Registry Key
Dim hDepth As Long '
Dim KeyValType As Long ' Data Type Of A Registry Key
Dim tmpVal As String ' Tempory Storage For A Registry Key Value
Dim KeyValSize As Long ' Size Of Registry Key Variable
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
tmpVal = String$(1024, 0) ' Allocate Variable Space
KeyValSize = 1024 ' Mark Variable Size
'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
Else ' WinNT Does NOT Null Terminate String...
tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
End If
'------------------------------------------------------------
' Determine Key Value Type For Conversion...
'------------------------------------------------------------
Select Case KeyValType ' Search Data Types...
Case REG_SZ ' String Registry Key Data Type
KeyVal = tmpVal ' Copy String Value
Case REG_DWORD ' Double Word Registry Key Data Type
For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
Next
KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
End Select
GetKeyValue = True ' Return Success
rc = RegCloseKey(hKey) ' Close Registry Key
Exit Function ' Exit
GetKeyError: ' Cleanup After An Error Has Occured...
KeyVal = "" ' Set Return Val To Empty String
GetKeyValue = False ' Return Failure
rc = RegCloseKey(hKey) ' Close Registry Key
End Function
frmGameOver :
Private Sub cmdOK_Click()
frmGameOver.Visible = False
fiCount1 = 10
fiCount2 = 10
fiCount3 = 10
fiCount4 = 10
fiCount5 = 10
fiCount6 = 10
fiCount7 = 10
fiCount8 = 10
fiCount9 = 10
fiScore = 0
frmGames.TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 9
'set initial start speeds for each timer
frmGames.Timer1.Interval = 1000
frmGames.Timer2.Interval = 1000
frmGames.Timer3.Interval = 1000
frmGames.Timer4.Interval = 1000
frmGames.Timer5.Interval = 1000
frmGames.Timer6.Interval = 1000
frmGames.Timer7.Interval = 1000
frmGames.Timer8.Interval = 1000
frmGames.Timer9.Interval = 1000
End Sub
gambar 1.0 ( contoh game )
gambar 1.7 ( frmGameOver Descriptione)
APLIKASI GAME 10 DETIK
Aplikasi game 10 detik merupakan sebuah game yang dibilang sederhana, cara memainkan game ini adalah dengan cara mengumpulkan poin – poin dari masing-masing pengeklikan tombol yang dimana setiap tombol memiliki nilai 10. Batas pengeklikan adalah 10 detk. Apabila anda mengeklik di luar 10 detik, maka tombol tidak akan dapat digunakan lagi. Pengumpulan poin tergantung pada kecepatan anda mengeklik masing-masing tombol. Anda akan menghasilkaan poin maksimal sebesar 21000.
MENDESAIN APLIKASI GAME 10 DETIK
Bukalah Ikon Visual Basic
Pilih Standart.Exe
Jika anda sudah memiliki form1, buat 2 form lagi : form2 and form3
Desain aplikasi game sesuai dengan keterangan di bawah ini
Ketikan Kode-kode berikut ini sesuai dengan masing-masing form
Option Explicit
' Declare countdown variables for each button. These will begin at 10
' and countdown by one with each buttons timer event.
Dim fiCount1 As Integer
Dim fiCount2 As Integer
Dim fiCount3 As Integer
Dim fiCount4 As Integer
Dim fiCount5 As Integer
Dim fiCount6 As Integer
Dim fiCount7 As Integer
Dim fiCount8 As Integer
Dim fiCount9 As Integer
'Declare countdown speed variables for each button. Each button will have its
'own random countdown speed which will decrease when the button is clicked.
Dim fiSpeed1 As Integer
Dim fiSpeed2 As Integer
Dim fiSpeed3 As Integer
Dim fiSpeed4 As Integer
Dim fiSpeed5 As Integer
Dim fiSpeed6 As Integer
Dim fiSpeed7 As Integer
Dim fiSpeed8 As Integer
Dim fiSpeed9 As Integer
'Declare variable for game score
Dim fiScore As Integer
Dim fiNumLeft As Integer
'Declare variable to check that same button has not been pressed twice so as to
'disable cheating by just clicking repeatedly on the button.
Dim fiLastPressed As Integer
Private Sub cmd1_Click()
If fiLastPressed <> 1 Then
fiCount1 = 10
cmd1.Caption = 10
Timer1.Interval = Timer1.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 1
End If
End Sub
Private Sub cmd2_Click()
If fiLastPressed <> 2 Then
fiCount2 = 10
cmd2.Caption = 10
Timer2.Interval = Timer2.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 2
End If
End Sub
Private Sub cmd3_Click()
If fiLastPressed <> 3 Then
fiCount3 = 10
cmd3.Caption = 10
Timer3.Interval = Timer3.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 3
End If
End Sub
Private Sub cmd4_Click()
If fiLastPressed <> 4 Then
fiCount4 = 10
cmd4.Caption = 10
Timer4.Interval = Timer4.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 4
End If
End Sub
Private Sub cmd5_Click()
If fiLastPressed <> 5 Then
fiCount5 = 10
cmd5.Caption = 10
Timer5.Interval = Timer5.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 5
End If
End Sub
Private Sub cmd6_Click()
If fiLastPressed <> 6 Then
fiCount6 = 10
cmd6.Caption = 10
Timer6.Interval = Timer6.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 6
End If
End Sub
Private Sub cmd7_Click()
If fiLastPressed <> 7 Then
fiCount7 = 10
cmd7.Caption = 10
Timer7.Interval = Timer7.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 7
End If
End Sub
Private Sub cmd8_Click()
If fiLastPressed <> 8 Then
fiCount8 = 10
cmd8.Caption = 10
Timer8.Interval = Timer8.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 8
End If
End Sub
Private Sub cmd9_Click()
If fiLastPressed <> 9 Then
fiCount9 = 10
cmd9.Caption = 10
Timer9.Interval = Timer9.Interval - 50
fiScore = fiScore + 10
TxtScore.Text = Str(fiScore)
fiLastPressed = 9
End If
End Sub
Private Sub cmdQuit_Click()
End
End Sub
Private Sub cmdStart_Click()
cmd1.Enabled = True
cmd2.Enabled = True
cmd3.Enabled = True
cmd4.Enabled = True
cmd5.Enabled = True
cmd6.Enabled = True
cmd7.Enabled = True
cmd8.Enabled = True
cmd9.Enabled = True
fiCount1 = 11
fiCount2 = 11
fiCount3 = 11
fiCount4 = 11
fiCount5 = 11
fiCount6 = 11
fiCount7 = 11
fiCount8 = 11
fiCount9 = 11
fiScore = 0
TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 8
'set initial start speeds for each timer
Timer1.Interval = 1000
Timer2.Interval = 1000
Timer3.Interval = 1000
Timer4.Interval = 1000
Timer5.Interval = 1000
Timer6.Interval = 1000
Timer7.Interval = 1000
Timer8.Interval = 1000
Timer9.Interval = 1000
'Start all timers counting down
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Timer4.Enabled = True
Timer5.Enabled = True
Timer6.Enabled = True
Timer7.Enabled = True
Timer8.Enabled = True
Timer9.Enabled = True
tmrEndGame.Enabled = True
End Sub
Private Sub Command1_Click()
frmAbout.Show
End Sub
Private Sub Form_Load()
fiCount1 = 10
fiCount2 = 10
fiCount3 = 10
fiCount4 = 10
fiCount5 = 10
fiCount6 = 10
fiCount7 = 10
fiCount8 = 10
fiCount9 = 10
fiScore = 0
TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 8
'set initial start speeds for each timer
Timer1.Interval = 1000
Timer2.Interval = 1000
Timer3.Interval = 1000
Timer4.Interval = 1000
Timer5.Interval = 1000
Timer6.Interval = 1000
Timer7.Interval = 1000
Timer8.Interval = 1000
Timer9.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If fiCount1 = 0 Then
Timer1.Enabled = False
cmd1.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount1 = fiCount1 - 1
cmd1.Caption = Str(fiCount1)
End If
End Sub
Private Sub Timer2_Timer()
If fiCount2 = 0 Then
Timer2.Enabled = False
cmd2.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount2 = fiCount2 - 1
cmd2.Caption = Str(fiCount2)
End If
End Sub
Private Sub Timer3_Timer()
If fiCount3 = 0 Then
Timer3.Enabled = False
cmd3.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount3 = fiCount3 - 1
cmd3.Caption = Str(fiCount3)
End If
End Sub
Private Sub Timer4_Timer()
If fiCount4 = 0 Then
Timer4.Enabled = False
cmd4.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount4 = fiCount4 - 1
cmd4.Caption = Str(fiCount4)
End If
End Sub
Private Sub Timer5_Timer()
If fiCount5 = 0 Then
Timer5.Enabled = False
cmd5.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount5 = fiCount5 - 1
cmd5.Caption = Str(fiCount5)
End If
End Sub
Private Sub Timer6_Timer()
If fiCount6 = 0 Then
Timer6.Enabled = False
cmd6.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount6 = fiCount6 - 1
cmd6.Caption = Str(fiCount6)
End If
End Sub
Private Sub Timer7_Timer()
If fiCount7 = 0 Then
Timer7.Enabled = False
cmd7.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount7 = fiCount7 - 1
cmd7.Caption = Str(fiCount7)
End If
End Sub
Private Sub Timer8_Timer()
If fiCount8 = 0 Then
Timer8.Enabled = False
cmd8.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount8 = fiCount8 - 1
cmd8.Caption = Str(fiCount8)
End If
End Sub
Private Sub Timer9_Timer()
If fiCount9 = 0 Then
Timer9.Enabled = False
cmd9.Enabled = False
fiNumLeft = fiNumLeft - 1
Else
fiCount9 = fiCount9 - 1
cmd9.Caption = Str(fiCount9)
End If
End Sub
Private Sub tmrEndGame_Timer()
If fiNumLeft = 0 Then
cmd1.Caption = "X"
cmd2.Caption = "X"
cmd3.Caption = "X"
cmd4.Caption = "X"
cmd5.Caption = "X"
cmd6.Caption = "X"
cmd7.Caption = "X"
cmd8.Caption = "X"
cmd9.Caption = "X"
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = False
Timer6.Enabled = False
Timer7.Enabled = False
Timer8.Enabled = False
Timer9.Enabled = False
frmGameOver.Visible = True
tmrEndGame.Enabled = False
End If
End Sub
frmAbout :
Option Explicit
' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
' Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_DWORD = 4 ' 32-bit number
Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
Const gREGVALSYSINFOLOC = "MSINFO"
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
Const gREGVALSYSINFO = "PATH"
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Sub cmdSysInfo_Click()
Call StartSysInfo
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Public Sub StartSysInfo()
On Error GoTo SysInfoErr
Dim rc As Long
Dim SysInfoPath As String
' Try To Get System Info Program Path\Name From Registry...
If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
' Try To Get System Info Program Path Only From Registry...
ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
' Validate Existance Of Known 32 Bit File Version
If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
' Error - File Can Not Be Found...
Else
GoTo SysInfoErr
End If
' Error - Registry Entry Can Not Be Found...
Else
GoTo SysInfoErr
End If
Call Shell(SysInfoPath, vbNormalFocus)
Exit Sub
SysInfoErr:
MsgBox "System Information Is Unavailable At This Time", vbOKOnly
End Sub
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
Dim i As Long ' Loop Counter
Dim rc As Long ' Return Code
Dim hKey As Long ' Handle To An Open Registry Key
Dim hDepth As Long '
Dim KeyValType As Long ' Data Type Of A Registry Key
Dim tmpVal As String ' Tempory Storage For A Registry Key Value
Dim KeyValSize As Long ' Size Of Registry Key Variable
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
tmpVal = String$(1024, 0) ' Allocate Variable Space
KeyValSize = 1024 ' Mark Variable Size
'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
Else ' WinNT Does NOT Null Terminate String...
tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
End If
'------------------------------------------------------------
' Determine Key Value Type For Conversion...
'------------------------------------------------------------
Select Case KeyValType ' Search Data Types...
Case REG_SZ ' String Registry Key Data Type
KeyVal = tmpVal ' Copy String Value
Case REG_DWORD ' Double Word Registry Key Data Type
For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
Next
KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
End Select
GetKeyValue = True ' Return Success
rc = RegCloseKey(hKey) ' Close Registry Key
Exit Function ' Exit
GetKeyError: ' Cleanup After An Error Has Occured...
KeyVal = "" ' Set Return Val To Empty String
GetKeyValue = False ' Return Failure
rc = RegCloseKey(hKey) ' Close Registry Key
End Function
frmGameOver :
Private Sub cmdOK_Click()
frmGameOver.Visible = False
fiCount1 = 10
fiCount2 = 10
fiCount3 = 10
fiCount4 = 10
fiCount5 = 10
fiCount6 = 10
fiCount7 = 10
fiCount8 = 10
fiCount9 = 10
fiScore = 0
frmGames.TxtScore.Text = "0"
fiLastPressed = 0
fiNumLeft = 9
'set initial start speeds for each timer
frmGames.Timer1.Interval = 1000
frmGames.Timer2.Interval = 1000
frmGames.Timer3.Interval = 1000
frmGames.Timer4.Interval = 1000
frmGames.Timer5.Interval = 1000
frmGames.Timer6.Interval = 1000
frmGames.Timer7.Interval = 1000
frmGames.Timer8.Interval = 1000
frmGames.Timer9.Interval = 1000
End Sub