Friday, May 31, 2013

VB.net with Listview Alarm Clock




Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Label1.Text = TimeOfDay

        For Each item As ListViewItem In Me.ListView1.Items
            If item.SubItems(0).Text = Me.Label1.Text Then
                MsgBox(item.SubItems(1).Text)
            End If
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Allow the user to remove the alarm
        If Me.ListView1.SelectedItems.Count > Nothing Then
            Me.ListView1.SelectedItems(0).Remove()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myAlarmTime As String
        Dim myAlarmName As String
        myAlarmTime = InputBox("Please add the time of the alarm")
        myAlarmName = InputBox("Please select a name")

        Dim lvitem As ListViewItem
        lvitem = Me.ListView1.Items.Add(myAlarmTime)
        lvitem.SubItems.Add(myAlarmName)

    End Sub
End Class

This code was copy right by RUPP Student

No comments:

Post a Comment