快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb点虐 写一个秒表 vb输入以秒为单位表示时间

用VB.NET设计一个以秒为基本单位的表,并且显示在窗体上的步骤,并且给出关键代码

是我以前自己设计的用来测试自己点钞速度用的,希望是你需要的

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:申请域名虚拟主机、营销软件、网站建设、象山网站维护、网站推广。

以下是窗体的全部代码

Public Class Form1

Dim StartFlag As Boolean = False

Dim secon As Integer

Dim minut As Integer

'空格

Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp

If e.KeyCode = Keys.Space Then

If StartFlag Then

StartFlag = False

Timer1.Enabled = False

If Val(Strings.Right(Label1.Text, 2))  10 And Val(Strings.Right(Label1.Text, 2)) = 0 Then secon = 0 : minut = 0 : Label1.Text = "00:00" : Exit Sub

ListBox1.Items.Add(Label1.Text.ToString)

ListBox1.SelectedItem = ListBox1.Items.Count - 1

Label1.Focus()

Button1.Enabled = True

Label1.Text = "00:00"

secon = 0

minut = 0

Else

StartFlag = True

Timer1.Enabled = True

End If

End If

End Sub

'加载

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ListBox1.Items.Clear()

Label1.Text = "00:00"

Button1.Enabled = False

secon = 0

minut = 0

Label1.Focus()

End Sub

'清空

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Button1.Enabled = False

ListBox1.Items.Clear()

Label1.Focus()

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

secon += 1

If secon = 60 Then

secon = 0

minut += 1

End If

Dim seconStr As String = secon

If seconStr.Length = 1 Then seconStr = "0" + seconStr

Dim minutStr As String = minut

If minutStr.Length = 1 Then minutStr = "0" + minutStr

Label1.Text = minutStr + ":" + seconStr

Label1.Focus()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim SeconSun As Integer

If ListBox1.Items.Count  0 Then

For i = 0 To ListBox1.Items.Count - 1

Dim TemStr As String = ListBox1.Items.Item(i).ToString

Dim TemInt1 As Integer = Val(Strings.Right(TemStr, 2))

Dim TemInt2 As Integer = Val(Strings.Left(TemStr, 2))

Debug.Print(TemInt1.ToString)

Debug.Print(TemInt2.ToString)

SeconSun += TemInt1 + TemInt2 * 60

Debug.Print(SeconSun.ToString)

Next

TextBox1.Text = (SeconSun / ListBox1.Items.Count).ToString + "秒"

End If

Label1.Focus()

End Sub

End Class

用VB编写一个秒表

'一个标签,两个按钮,一个计时器。

'标签显示时间,按钮一控制秒表,按钮二清零。

Dim m As Integer, s As Integer, ms As Integer, flag As Boolean

Private Sub Command1_Click()

If flag = False Then

Timer1.Interval = 10

flag = True

Else

Timer1.Interval = 0

flag = False

End If

End Sub

Private Sub Command2_Click()

flag = False

Timer1.Interval = 0

m = 0

s = 0

ms = 0

Label1.Caption = "00:00:00"

End Sub

Private Sub Timer1_Timer()

ms = ms + 1

If ms = 100 Then

s = s + 1

ms = 0

End If

If s = 60 Then

m = m + 1

s = 0

End If

Label1.Caption = Format(m, "00:") Format(s, "00:") Format(ms, "00")

End Sub

求助,如何用vb点虐 编写一个秒表

Dim tCount As Integer '用来计数

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

tCount = 10

Timer1.Interval = 1000 '每秒执行一次

Timer1.Enabled = True

End

Sub

Private Sub

Timer1_Tick(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Timer1.Tick

tCount -= 1

If tCount = 0 Then

MessageBox.Show("时间到")

Timer1.Enabled = False

End If

End

Sub


分享文章:vb点虐 写一个秒表 vb输入以秒为单位表示时间
当前URL:http://6mz.cn/article/ddjiphg.html

其他资讯