I am trying to figure out how when a name typed in textbox1 on Form2 and a date is selected in the DateTimePicker box on Form2 that the name will show in textbox3 on Form1 when the date in MonthCalendar is pressed. I.E. Form2 opens and I enter the name David and below it I select the date March 10, 2014 and click ok. On Form1 I click March 10, 2014 on the MonthCalendar and in the textbox3 on Form1 will show David and every 10 business days his name will display on that date. So his name will show on March 10th and then again on March 24th and so on. Needing this to be able to add multiple names like in a list. Also....and this may not be able to happen....I have another form3 so can input days that need to be omitted. So if David's name shows on the 10th and I need the 12th omitted then instead of David showing on the 24th he will show on the 25th.
When program opens, it opens Form1
When click on Edit> click on Schedule
Opens Form2
Input Name and select color either Red or Yellow, select a Test Type, and Start Date. Depending on the color determines the days that needs till next recurrence. Red means every 10 days they need to be tested and yellow means every 20 days. Then click ok
Form2 closes and on Form1, depending on the color chosen it puts the name with the test beside it in the corresponding column.
When clicking on the date that was selected as the start date it should populate into textbox3 labeled Today’s Schedule.
This all works fine but when I click on dates after the start date (IE 3/5, 3/6, etc) it keeps listing the names which is not what I am needing. I am needing for the names in the red column to show up once every 10 days and yellow every 20 days and to only show up on the date that is clicked.
Here is the full code for Form1:
Public Class Form1
Dim FP As String
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub StudentScheduleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StudentScheduleToolStripMenuItem.Click
If Form2.ShowDialog = Windows.Forms.DialogResult.OK Then
If Form2.ComboBox2.SelectedItem = "Select Test Type" Then
MessageBox.Show("Please select a test type!")
ElseIf Form2.ComboBox2.SelectedItem = "FSF" Then
Form2.TextBox1.Text += " (FSF)"
ElseIf Form2.ComboBox2.SelectedItem = "LNF" Then
Form2.TextBox1.Text += " (LNF)"
ElseIf Form2.ComboBox2.SelectedItem = "PSF" Then
Form2.TextBox1.Text += " (PSF)"
ElseIf Form2.ComboBox2.SelectedItem = "NWF" Then
Form2.TextBox1.Text += " (NWF)"
ElseIf Form2.ComboBox2.SelectedItem = "DORF" Then
Form2.TextBox1.Text += " (DORF)"
ElseIf Form2.ComboBox2.SelectedItem = "DAZE" Then
Form2.TextBox1.Text += " (DAZE)"
ElseIf Form2.ComboBox2.SelectedItem = "WR" Then
Form2.TextBox1.Text += " (WR)"
ElseIf Form2.ComboBox2.SelectedItem = "TRC" Then
Form2.TextBox1.Text += " (TRC)"
End If
Select Case Form2.ComboBox1.SelectedItem.ToString.ToLower
Case "red"
TextBox1.AppendText(Form2.TextBox1.Text & Environment.NewLine)
Case "yellow"
TextBox2.AppendText(Form2.TextBox1.Text & Environment.NewLine)
Case Else
MessageBox.Show("Please select a color!")
End Select
End If
End Sub
Private Sub DaysToOmitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DaysToOmitToolStripMenuItem.Click
Dim daysomit As New Form3
daysomit.Show()
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Dim About As New AboutBox2
About.Show()
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
My.Computer.FileSystem.WriteAllText("Log.spms", TextBox1.Text, False)
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim Open As New OpenFileDialog()
Open.Filter = "Student Progress Monitoring Schedule (*.spms)|*.spms|All Files(*.*)|*.*"
Open.Title = "Open"
Try
If Open.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = My.Computer.FileSystem.ReadAllText("Log.spms")
Me.Text = "Text Editor" + Open.FileName
FP = Open.FileName
End If
Catch ex As Exception
End Try
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If Form2.Status = Windows.Forms.DialogResult.OK Then
Dim name As String = Form2.TextBox1.Text.Trim()
Dim dateEntered As Date = Form2.DateTimePicker1.Value.Date
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = My.Computer.FileSystem.ReadAllText("Log.spms")
End Sub
Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
TextBox3.AppendText(TextBox1.Text & TextBox2.Text & Environment.NewLine)
End Sub
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
TextBox1.Text = My.Computer.FileSystem.ReadAllText("New.spms")
End Sub
End Class
And here is the full code for Form2:
Public Class Form2
Inherits Form
Friend WithEvents tbName As New System.Windows.Forms.TextBox
Friend WithEvents dtpKeyDate As New System.Windows.Forms.DateTimePicker
Friend WithEvents btnOk As New System.Windows.Forms.Button
Friend WithEvents btnCancel As New System.Windows.Forms.Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.TextLength > 0 AndAlso ComboBox1.SelectedIndex <> -1 Then
Me.DialogResult = Windows.Forms.DialogResult.OK
End If
End Sub
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Clear()
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
DateTimePicker1.Value = Now
End Sub
Friend Status As System.Windows.Forms.DialogResult = Windows.Forms.DialogResult.Cancel
End Class
Again everything is working fine except the 10 and 20 day recurrence and names are not clearing on each date clicked.