0

如果有人可以帮助我使用这个程序,我将不胜感激。

基本上,该程序会在电视节目开始前 5 分钟和 30 分钟提醒用户,它具有用于节目名称、频道和播放时间的 Tex-box 输入。输入应该进入列表框,然后当时间到达时,它会显示一个消息框,说明程序在 5/30 分钟后启动。

我无法从列表中获取索引(list_box_tv_shows.TabIndex = 0),当程序运行时,它只是不断重复(list_box_tv_shows.TabIndex = 0)中的第一项。

Public Class frm_main_window

Dim time_format As New DateTime

Private Sub tmr_current_time_label_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_current_time_label.Tick

    lbl_current_time.Text = Format(Now, "hh:mm:ss tt")

    lbl_5min_time.Text = Format(Now.AddMinutes(5), "hh:mm:ss tt")
    lbl_30min_time.Text = Format(Now.AddMinutes(30), "hh:mm:ss tt")

    '----------------------------------------------------------------------------------------------------------------------------------

    If list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 0 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(0) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 1 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(1) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 2 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(2) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 3 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(4) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 4 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(4) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 5 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(5) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 6 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(6) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 7 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(7) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 8 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(8) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_5min_time.Text) And list_box_tv_shows.TabIndex = 9 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(9) & " " & "is starting in 5 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    End If

    '------------------------------------------------------------------------------------------------------------------------

    If list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.SelectedIndex = 0 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(0) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.SelectedIndex = 1 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(1) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 2 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(2) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 3 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(3) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 4 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(4) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 5 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(5) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 6 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(6) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 7 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(7) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 8 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(8) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    ElseIf list_box_program_time_hide.Items.Contains(lbl_30min_time.Text) And list_box_tv_shows.TabIndex = 9 Then
        tmr_current_time_label.Stop()
        MsgBox(list_box_program_name.Items(9) & " " & "is starting in 30 minutes")
        If MsgBoxResult.Ok Then
            tmr_current_time_label.Start()
        End If
    End If

End Sub

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

    lbl_current_time.Text = Format(Now, "hh:mm:ss tt")

    lbl_program_time_goes_into_list.Hide()
    list_box_program_time_hide.Hide()
    list_box_program_name.Hide()
    lbl_30min_time.Show()
    lbl_5min_time.show()

End Sub

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

    list_box_tv_shows.Items.Clear()

    lbl_program_time_goes_into_list.Text = cbo_hours.Text & ":" & cbo_min.Text & ":" & cbo_sec.Text & " " & cbo_am_or_pm.Text

    list_box_program_time_hide.Items.Add(lbl_program_time_goes_into_list.Text)
    list_box_program_name.Items.Add(txt_box_program_name.Text)
    list_box_tv_shows.Items.Add(txt_box_program_name.Text & " | " & txt_box_tv_channel.Text & " | " & lbl_program_time_goes_into_list.Text)

End Sub

End Class
4

1 回答 1

0

只需在您的计时器事件中执行此操作。为 30 分钟版本添加另一个(或创建一个可重复使用的子,因为唯一改变的是您要查找的内容和显示)。我可能会使用 dataGridView 所以你没有多个列表框

    For Each i As String In list_box_program_time_hide.Items
        If i.Contains(lbl_5min_time.Text) Then
            tmr_current_time_label.Stop()
            MsgBox(list_box_program_name.Items(i.indexof) & " " & "is starting in 5 minutes")
            If MsgBoxResult.Ok Then
                tmr_current_time_label.Start()
            End If
            tmr_current_time_label.Start()
        End If
    Next
于 2013-05-07T20:19:11.097 回答