1
我對使用Visual Basics進行編碼相當新穎。我正在開發一個項目,我需要在列表中創建多個項目,並且每個列表的末尾都有一個計時器,這些計時器在按下「開始」按鈕時單獨計數。 目前的問題是,當定時器增加計數時,我一直無法更新索引。 Form Design Picture Here 我在下面列出了我的代碼。任何有關如何實現這一點的反饋都會有很大的幫助。如何使用定時器輸出更新Listbox索引
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
我很困惑。請更詳細地解釋!你的ListBox中會有多個條目/行嗎?哪些線與他們的櫃檯需要更新。解釋「t」值是怎麼回事。 –
列表框將有多行。 t值從左至右依次代表文本框(見圖片https://i.stack.imgur.com/aFWRX.png)及其輸入。 t1 - t2 - t3 - t4 - count.text 示例:Hello - 3 - David - 描述 - 「Timer」 – AdamO