📄 form1.vb
字号:
Me.lblTime.Font = New System.Drawing.Font("Times New Roman", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTime.Location = New System.Drawing.Point(8, 88)
Me.lblTime.Name = "lblTime"
Me.lblTime.Size = New System.Drawing.Size(200, 16)
Me.lblTime.TabIndex = 13
Me.lblTime.Text = "Elapsed Time: "
Me.lblTime.Visible = False
'
'lblResolution
'
Me.lblResolution.BackColor = System.Drawing.Color.MediumPurple
Me.lblResolution.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lblResolution.Font = New System.Drawing.Font("Times New Roman", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblResolution.Location = New System.Drawing.Point(8, 64)
Me.lblResolution.Name = "lblResolution"
Me.lblResolution.Size = New System.Drawing.Size(192, 16)
Me.lblResolution.TabIndex = 14
Me.lblResolution.Text = "Stopwatch Resolution: "
'
'gbTime
'
Me.gbTime.BackColor = System.Drawing.Color.MediumPurple
Me.gbTime.Controls.Add(Me.lblTime)
Me.gbTime.Controls.Add(Me.lblSeconds)
Me.gbTime.Controls.Add(Me.lblMinutes)
Me.gbTime.Controls.Add(Me.lblMilli)
Me.gbTime.Font = New System.Drawing.Font("Times New Roman", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.gbTime.Location = New System.Drawing.Point(8, 6)
Me.gbTime.Name = "gbTime"
Me.gbTime.Size = New System.Drawing.Size(216, 90)
Me.gbTime.TabIndex = 15
Me.gbTime.TabStop = False
Me.gbTime.Text = "Elapsed Timer Values"
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.GroupBox1.Controls.Add(Me.lblResolution)
Me.GroupBox1.Controls.Add(Me.lblRunning)
Me.GroupBox1.Controls.Add(Me.lblWatchReset)
Me.GroupBox1.Font = New System.Drawing.Font("Times New Roman", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GroupBox1.Location = New System.Drawing.Point(232, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(208, 88)
Me.GroupBox1.TabIndex = 16
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "StopWatch Stats"
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(147, Byte), CType(119, Byte), CType(172, Byte))
Me.ClientSize = New System.Drawing.Size(448, 128)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.gbTime)
Me.Controls.Add(Me.btnStartReset)
Me.Controls.Add(Me.btnStop)
Me.Controls.Add(Me.btnStart)
Me.Font = New System.Drawing.Font("Times New Roman", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.Name = "frmMain"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = " csStopWatch Library v1.1 *Basic* - Example App"
Me.gbTime.ResumeLayout(False)
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
'stop the watch from running
stopWatch.stopWatch()
'update the watch running status
lblRunning.Text = "StopWatch Running: " & stopWatch.running.ToString
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
'start the watch timer but do not reset it
stopWatch.startNoReset()
'update various stats related to the stopWatch
lblResolution.Text = "StopWatch Resolution: " & stopWatch.watchResolution.ToString & " sec"
lblRunning.Text = "StopWatch Running: " & stopWatch.running
lblWatchReset.Text = "Watch Reseted: False"
'Give focus to the stop button right away. The focus could stick
'to this button until the mouse is pressed a couple times since
'there is a loop running continuously until the stop button is
'clicked .This will make it so the stop button will have focus
'on it right away.
btnStop.Focus()
Do
'allow windows to process other processes
System.Windows.Forms.Application.DoEvents()
'update the various timed data
lblMilli.Text = "Elapsed Milliseconds: " & _
stopWatch.elapsedMilliSeconds.ToString
lblMinutes.Text = "Elapsed Minutes: " & _
stopWatch.elapsedMinutes.ToString
lblTime.Text = "Elapsed Time: " & _
stopWatch.elapsedTime.ToString
'give it a more user friendly look my putting a 0 in front of the number if it is below 9
If stopWatch.elapsedSeconds < 10 Then
lblSeconds.Text = "Elapsed Seconds: 0" & _
stopWatch.elapsedSeconds.ToString
Else
lblSeconds.Text = "Elapsed Seconds: " & _
stopWatch.elapsedSeconds.ToString
End If
Loop Until stopWatch.running = False
'update the watch running status
lblRunning.Text = "StopWatch Running: " & stopWatch.running
'give the stop button focus right away
btnStop.Focus()
End Sub
Private Sub btnStartReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartReset.Click
'start the stop watch and reset the watch
stopWatch.startWithReset()
'display the resolution of the stop watch based on seconds
lblResolution.Text = "StopWatch Resolution: " & stopWatch.watchResolution.ToString & " sec"
'display whether the stop watch is running or not
lblRunning.Text = "StopWatch Running: " & stopWatch.running
'display that the stop watch was reset
lblWatchReset.Text = "Watch Reseted: True"
'Give focus to the stop button right away. The focus could stick
'to this button until the mouse is pressed a couple times since
'there is a loop running continuously until the stop button is
'clicked .This will make it so the stop button will have focus
'on it right away.
btnStop.Focus()
Do
'keep the app's thread from freezing
System.Windows.Forms.Application.DoEvents()
'update the various watch time data
lblMilli.Text = "Elapsed Milliseconds: " & stopWatch.elapsedMilliSeconds.ToString
lblMinutes.Text = "Elapsed Minutes: " & stopWatch.elapsedMinutes.ToString 'Strings.FormatNumber(stopWatch.elapsedMinutes.ToString)
lblTime.Text = "Elapsed Time: " & stopWatch.elapsedTime.ToString
'
'give it a more user friendly look by putting a 0 in front
'of single digit numbers
If stopWatch.elapsedSeconds < 10 Then
lblSeconds.Text = "Elapsed Seconds: 0" & stopWatch.elapsedSeconds.ToString
Else
lblSeconds.Text = "Elapsed Seconds: " & stopWatch.elapsedSeconds.ToString
End If
Loop Until stopWatch.running = False
lblRunning.Text = "StopWatch Running: " & stopWatch.running
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -