Me.MonthCalendar1.BoldedDates = New System.DateTime() {New System.DateTime(2009, 6, 24, 0, 0, 0, 0)}
but I have no idea how I could add this to the Form1_Load sub from the Add Note button. So when the program is opened, the dates with notes are highlighted (bolded). The date format is completely different. Any help or fresh ideas would be greatly appreciated. Here's the code I have so far. Thanks
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private strSQL As String = ""
Private command As OleDbCommand
Private connection As OleDbConnection = New OleDbConnection(My.Settings.notesConnectionString)
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
txtDates.Text = MonthCalendar1.Selectionstart.ToShortDateString
btnAddNote.Hide()
txtNotes.Select()
txtNotes.Selectionstart = txtNotes.TextLength
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Me.MonthCalendar1.BoldedDates = New System.DateTime() {New System.DateTime(2009, 6, 24, 0, 0, 0, 0)}
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNotes.TextChanged
btnAddNote.Show()
End Sub
Private Sub btnAddNote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNote.Click
Try
Dim day As String
day = txtDates.Text
Dim note As String
note = txtNotes.Text
connection.Open()
If txtNotes.Text = "" Then
MessageBox.Show("Type a note, then press Enter...", "Warning !!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtNotes.Select()
Else
strSQL = "DELETE FROM calendar WHERE day = '" & day & "'"
command = New OleDbCommand(strSQL, connection)
command.ExecuteNonQuery()
strSQL = "Insert into calendar([day], [note]) Values('" & day & "', '" & note & "')"
command = New OleDbCommand(strSQL, connection)
command.ExecuteNonQuery()
connection.Close()
End If
Catch ex As Exception
MessageBox.Show("An error occurred, please restart Calendar and try again...", "Warning !!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
btnAddNote.Hide()
connection.Close()
End Sub
Private Sub txtDates_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDates.TextChanged
cn = New OleDbConnection(My.Settings.notesConnectionString)
'provider to be used when working with access database
cn.Open()
Try
txtNotes.Clear()
cmd = New OleDbCommand("Select note FROM calendar where day = '" & txtDates.Text & "'", cn)
dr = cmd.ExecuteReader
While dr.Read()
txtNotes.Text = CStr(dr(0))
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
This post has been edited by jimdandy75: 29 June 2009 - 06:28 PM

New Topic/Question
Reply




MultiQuote




|