【发布时间】:2017-06-03 12:30:36
【问题描述】:
我对使用 Visual Basics 进行编码相当陌生。我正在做一个项目,我需要在一个列表中创建多个项目,并且在每个列表的末尾都有一个计时器,用于在按下“开始”按钮时单独计数。 目前的问题是当计时器增加计数时我无法更新索引。 Form Design Picture Here 我在下面列出了我的代码。任何关于如何实现这一点的反馈都会有很大帮助。
Public Class Form1
Dim t1, t2, t3, t4 As Object
Dim count As Object
Public Sub GlobalTimerTick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
count.Text = Val(count.Text) + 1
ListBox1.Update()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
count = New System.Windows.Forms.Label
count.Text = 0
t1 = TextBox1.Text
t2 = TextBox2.Text
t3 = TextBox3.Text
t4 = TextBox4.Text
ListBox1.Items.Add("P" + t1 + " - " + t2 + " - " + t3 + " - " + t4 + " - " + count.text)
If (t1 = "") Then
MsgBox("Please enter a P-Level number.")
ElseIf (t1 = 0) Then
Timer1.Start()
ElseIf (t1 = 1) Then
ElseIf (t1 = 2) Then
ElseIf (t1 = 3) Then
ElseIf (t1 = 4) Then
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
Timer1.Stop()
End Sub
End Class
【问题讨论】:
-
我很困惑。请详细说明!您的列表框中会有多个条目/行吗?哪些行及其计数器需要更新。解释“t”值的含义。
-
列表框会有多行。 t 值按从左到右的顺序表示文本框(见图:i.stack.imgur.com/aFWRX.png)和它们的输入。 t1 - t2 - t3 - t4 - count.text 示例:Hello - 3 - David - Description - "Timer"
标签: vb.net vba timer listbox listboxitem