使用VB 2010创建电视提醒

时间:2013-05-07 18:35:05

标签: vb.net

如果有人能帮我解决这个问题,我将不胜感激。

基本上,节目在电视节目开始前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

1 个答案:

答案 0 :(得分: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