i am still trying to get this right and am just not getting it LOL.
i want to be able to set multiple reminder type alarms - allowing me to select a specific date from datetime picker and typing in my required time-
then hold them in a listview.
when the date and the time = todays date and todays time- i want a dialog box to show (this is using the colName txt).
this is all of the coding i have on this so far- and as you can see, some of it is commented out- because those attempts did not work.
i had it working when i was just wanting it to go by the time. but what if i dont want to make my reminder for today? i want to make one for next month sometime- and thats when all hell broke loose LOLLLLL!
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Public Class frmReminder
Private IsFileSaved As Boolean = False
Public ReminderIsSaved As Boolean = True
#Region "Loads"
Private Sub frmReminder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReadReminderList()
lblDateDisp.Text = Date.Now
lblDispTime.Text = TimeOfDay
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.lblDispTime.Text = TimeOfDay 'runs the timer label
''''''''' '''''' '''For Each item As ListViewItem In Me.Listview1.Items
'''''''' ' If item.SubItems(0).Text = Me.lblDispTime.Text Then
'''''''' ' MsgBox(item.SubItems(1).Text)
'''''''' ' End If
''''''''' 'Next
''''''''' ''For Each item As ListViewItem In Me.Listview1.Items
'''''''' '' If item.SubItems(0).Text = Me.lblDateDisp.Text AndAlso item.SubItems(1).Text = lblDispTime.Text Then
'''''''''' MsgBox(item.SubItems(2).Text)
'''''''' '' End If
''''''''''''' ''Next
For Each item As ListViewItem In Me.ListView1.Items
If item.SubItems(0).Text = Date.Now And item.SubItems(1).Text = TimeOfDay Then
MsgBox(item.SubItems(2).Text)
End If
Next
End Sub
Private Sub ReadReminderList()
If Not System.IO.File.Exists(Application.StartupPath & "\ReminderList.xml") Then Exit Sub
Dim doc As New XmlDocument
Try
doc.Load(Application.StartupPath & "\ReminderList.xml")
For Each node As XmlNode In doc.SelectNodes("//Item")
Dim item As New ListViewItem
Dim nodeAttributes As XmlAttributeCollection = node.Attributes
item.Text = nodeAttributes(0).InnerText
item.SubItems.Add(nodeAttributes(1).InnerText)
item.SubItems.Add(nodeAttributes(2).InnerText)
Listview1.Items.Add(item)
Next
doc = Nothing
Catch ex As Exception
Listview1.Items.Clear()
End Try
End Sub
#End Region
#Region "Events"
Private Sub btnRemSel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemSel.Click
If Listview1.SelectedIndices.Count > 0 Then
If MessageBox.Show("Are You Sure You Want To Delete This Reminder?", "Remove Reminder", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
For i As Integer = Listview1.SelectedIndices.Count - 1 To 0 Step -1
Listview1.Items.RemoveAt(Listview1.SelectedIndices(i))
ReminderIsSaved = False
Next
End If
End If
SaveReminderList()
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'Identify what we are wanting to add
Dim myAlarmDate As String '0
Dim myAlarmTime As String '1
Dim myAlarmName As String '2
'locating what we are adding
myAlarmDate = dtpSelect.Text
myAlarmTime = txtAlTime.Text
myAlarmName = txtAlText.Text
'adding the items into the listview
Dim Lvitem As ListViewItem
Lvitem = Me.Listview1.Items.Add(myAlarmDate)
Lvitem.SubItems.Add(myAlarmTime)
Lvitem.SubItems.Add(myAlarmName)
'Clearing the textboxes for another entry
dtpSelect.Text = Date.Now
txtAlTime.Text = ""
txtAlText.Text = ""
If File.Exists(Application.StartupPath & "\ReminderList.xml") Then
File.Delete(Application.StartupPath & "\ReminderList.xml")
End If
SaveReminderList()
End Sub
#End Region
#Region "Closing"
Private Sub frmReminder_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Msg As String = "Are you sure you want to close the reminder?" & Environment.NewLine & Environment.NewLine
Msg &= "If you close the reminder you will not be reminded" & Environment.NewLine
Msg &= "Use Minimize to send Reminder to the task bar!"
If MessageBox.Show(Msg, "Exiting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
e.Cancel = True
End If
End Sub
Private Sub SaveReminderList()
Dim writer As XmlTextWriter = New XmlTextWriter(Application.StartupPath & "\ReminderList.xml", System.Text.Encoding.Unicode)
writer.Formatting = Formatting.Indented
writer.Indentation = 4
writer.WriteStartDocument()
writer.WriteWhitespace(Environment.NewLine)
writer.WriteStartElement("Reminder")
writer.WriteWhitespace(Environment.NewLine)
For i As Integer = 0 To Listview1.Items.Count - 1
writer.WriteStartElement("Item")
writer.WriteAttributeString("Date", Listview1.Items(i).SubItems(0).Text)
writer.WriteAttributeString("Time", Listview1.Items(i).SubItems(1).Text)
writer.WriteAttributeString("Name", Listview1.Items(i).SubItems(2).Text)
writer.WriteEndElement()
writer.WriteWhitespace(Environment.NewLine)
Next
writer.WriteEndElement()
writer.WriteWhitespace(Environment.NewLine)
writer.WriteEndDocument()
writer.Close()
End Sub
#End Region
#Region "Hide and Show"
Private Sub frmReminder_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If WindowState = FormWindowState.Minimized Then
Me.Visible = False
End If
End Sub
Private Sub Reminder_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Reminder.MouseClick
If WindowState = FormWindowState.Normal Then
Me.Visible = False
End If
End Sub
Private Sub Reminder_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Reminder.MouseDoubleClick
Me.Visible = True
If WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub
Private Sub ShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowToolStripMenuItem.Click
Me.Visible = True
If WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub
Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
Me.Visible = True
If WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub
#End Region
End Class