Game again

This is the game iv'e been doing for a while, its the one based on a childs game and works by changing the cell properties.
like so
342
156
78empty cell
by clicking on the numbers they move, the object is to finish like so
123
456
78
Iv'e pasted the code below and it works very well the numbers appear randomly now but i would like to include a timer to show how long the game has taken.
And a message box that could say who has posted the best time, can you help.
 Option Explicit
Dim x as Integer
Dim Temp
private Sub cmd1_click( )
If ((cmd1.Top = mtcell.Top) And (ABS(mtcell.Left - cmd1.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd1.Left
      cmd1.Left = Temp
End If
If ((cmd1.Left = mtcell.Left) And (ABS(cmd1.Top - mtcell.Top) = 1440)) Then
      Temp = cmd1.Top
      cmd1.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd2_click( )
If ((cmd2.Top = mtcell.Top) And (ABS(mtcell.Left - cmd2.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd2.Left
      cmd2.Left = Temp
End If
If ((cmd2.Left = mtcell.Left) And (ABS(cmd2.Top - mtcell.Top) = 1440)) Then
      Temp = cmd2.Top
      cmd2.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd3_click( )
If ((cmd3.Top = mtcell.Top) And (ABS(mtcell.Left - cmd3.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd3.Left
      cmd3.Left = Temp
End If
If ((cmd3.Left = mtcell.Left) And (ABS(cmd3.Top - mtcell.Top) = 1440)) Then
      Temp = cmd3.Top
      cmd3.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd4_click( )
If ((cmd4.Top = mtcell.Top) And (ABS(mtcell.Left - cmd4.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd4.Left
      cmd4.Left = Temp
End If
If ((cmd4.Left = mtcell.Left) And (ABS(cmd4.Top - mtcell.Top) = 1440)) Then
      Temp = cmd4.Top
      cmd4.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd5_click( )
If ((cmd5.Top = mtcell.Top) And (ABS(mtcell.Left - cmd5.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd5.Left
      cmd5.Left = Temp
End If
If ((cmd5.Left = mtcell.Left) And (ABS(cmd5.Top - mtcell.Top) = 1440)) Then
      Temp = cmd5.Top
      cmd5.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd6_click( )
If ((cmd6.Top = mtcell.Top) And (ABS(mtcell.Left - cmd6.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd6.Left
      cmd6.Left = Temp
End If
If ((cmd6.Left = mtcell.Left) And (ABS(cmd6.Top - mtcell.Top) = 1440)) Then
      Temp = cmd6.Top
      cmd6.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd7_click( )
If ((cmd7.Top = mtcell.Top) And (ABS(mtcell.Left - cmd7.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd7.Left
      cmd7.Left = Temp
End If
If ((cmd7.Left = mtcell.Left) And (ABS(cmd7.Top - mtcell.Top) = 1440)) Then
      Temp = cmd7.Top
      cmd7.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

private Sub cmd8_click( )
If ((cmd8.Top = mtcell.Top) And (ABS(mtcell.Left - cmd8.Left) = 1680)) Then
      Temp = mtcell.Left
      mtcell.left = cmd8.Left
      cmd8.Left = Temp
End If
If ((cmd8.Left = mtcell.Left) And (ABS(cmd8.Top - mtcell.Top) = 1440)) Then
      Temp = cmd8.Top
      cmd8.Top = mtcell.Top
      mtcell.Top = Temp
End If
End Sub

Sub LoadButtons()
Dim RndIndex(1 To 8) As Integer
Dim MyValue As Integer
Dim iVal As Integer
Dim jVal As Integer
Dim Vswitch As Boolean
Randomize ' Initialize random-number generator.
For iVal = 1 To 8
MyValue = Int((8 * Rnd) + 1) ' Generate random value between 1 and 8.
Do
Vswitch = False
For jVal = 1 To iVal
If RndIndex(jVal) = MyValue Then Vswitch = True
Next jVal
If Vswitch = False Then Exit Do
MyValue = MyValue + 1
If MyValue = 9 Then MyValue = 1
Loop
RndIndex(iVal) = MyValue
Next iVal
Cmd1.Caption = CStr(RndIndex(1))
Cmd2.Caption = CStr(RndIndex(2))
Cmd3.Caption = CStr(RndIndex(3))
Cmd4.Caption = CStr(RndIndex(4))
Cmd5.Caption = CStr(RndIndex(5))
Cmd6.Caption = CStr(RndIndex(6))
Cmd7.Caption = CStr(RndIndex(7))
Cmd8.Caption = CStr(RndIndex(8))
End Sub
 
dypseyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
In your form, you can set the following in the DECLARATIONS SECTION:

    Public StartTime As Date

Then when you start your game, do this:

    StartTime = Now

and when you stop your game, do this:


    Dim iVal As Long
    iVal = DateDiff("S", StartTime, Now)

Ival will contain the number of second the game took.

You can save off your scores and time by doing the SaveSetting and GetSetting calls...


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
Glad I could help! Thanks for the points!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.