Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents btnReset As System.Windows.Forms.Button Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.btnReset = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Timer1 ' Me.Timer1.Interval = 10000 ' 'btnReset ' Me.btnReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.btnReset.Location = New System.Drawing.Point(696, 496) Me.btnReset.Name = "btnReset" Me.btnReset.Size = New System.Drawing.Size(72, 32) Me.btnReset.TabIndex = 0 Me.btnReset.Text = "Reset" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(768, 526) Me.Controls.Add(Me.btnReset) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Structure frmControl Dim btn As Button Dim lbl As Label End Structure Dim frmControls(9) As frmControl Dim WithEvents b As Button Dim l As Label Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.WindowState = FormWindowState.Maximized Dim xMove As Integer = Me.Width / 11 Dim yMove As Integer = Me.Height / 11 Dim location As New System.Drawing.Point(10, 10) For i As Integer = 0 To 9 b = New Button If i = 0 Then b.Name = "btnHome" b.Text = "&Home" AddHandler b.Click, AddressOf btnHome_Click Else b.Name = "btn" & i b.Text = "&" & i b.Tag = i AddHandler b.Click, AddressOf btn_Click End If b.Location = location location.X += xMove location.Y += yMove b.Enabled = False Me.Controls.Add(b) frmControls(i).btn = b 'add reference l = New Label l.Location = b.Location l.Left += b.Width + 3 Me.Controls.Add(l) frmControls(i).lbl = l Next hit(9) 'as if last hit button 10 End Sub Dim t As Date Private Sub hit(ByVal index As Integer) If t.Ticks <> 0 Then Dim delta = Now.Subtract(t).Ticks frmControls(index).lbl.Text = FormatNumber(delta / 10000, 2) End If frmControls(index).btn.Enabled = False frmControls(0).btn.Enabled = True t = Now End Sub Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim i As Integer = sender.tag hit(i) End Sub Private nextBtn As Integer Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) t = Now nextBtn += 1 If nextBtn > 9 Then nextBtn = 1 frmControls(nextBtn).btn.Enabled = True frmControls(0).btn.Enabled = False Timer1.Enabled = True End Sub Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click hit(9) nextBtn = 0 End Sub End Class