daddydonkykong's Profile
Reputation: 2
Apprentice
- Group:
- Members
- Active Posts:
- 23 (0.05 per day)
- Joined:
- 26-March 12
- Profile Views:
- 545
- Last Active:
Apr 16 2012 06:03 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Textbox entry on one form to change text output on another form
Posted 11 Apr 2012
DimitriV, on 11 April 2012 - 07:28 PM, said:So when you close frmStudentName you want it to clear frmMain.gbxSchedule.Text?
Spoiler
Yes, only when the cancel click event is used tho.
So i need to somehow create properties for the cancel and accept click events on the MAIN FORM and declare them in both places that I have the code in the main form telling it to change gbxSchedule on the MAIN and SCHEDULE forms...
I know you dont want to, but if you'd download the zip you would understand what i mean in .5 seconds... -
In Topic: Textbox entry on one form to change text output on another form
Posted 11 Apr 2012
DimitriV, on 11 April 2012 - 04:31 PM, said:Hang on, what? The code for btnCancel and btnAccept is identical!
Yes, because they both close the form... The subform frmStudentName is not where the code goes... They just both close the form and send you back to the main form.
The code that snatches the input out of txtStudentName.Text is on the main form. here i'll post the snippets...
This is code from bottom of main form that calls up the Enter Name Box and then sends the input to gbxSchedule.Text on the main form
rivate Sub btnEnterStudent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterStudent.Click frmStudentName.ShowDialog() If frmStudentName.txtStudentName.Text <> "" Then gbxSchedule.Text = "Course Information for " & frmStudentName.txtStudentName.Text End If End Sub
And this is the code from the main form that snatches the input from the Name Box and puts it in gbx.Schedule on the Schedule Form...
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click ' This procedure displays the schedule on an ' instance of the frmSchedule form. Dim scheduleForm As New frmSchedule Dim gbxSchedule As String If frmStudentName.txtStudentName.Text <> "" Then scheduleForm.gbxSchedule.Text = "Schedule for " & frmStudentName.txtStudentName.Text End If -
In Topic: Textbox entry on one form to change text output on another form
Posted 11 Apr 2012
While running the program through the ropes to double check everything, i noticed that btnCancel on frmStudentName form doesn't cancel and leave gbxSchedule.Text on the frmMain form unchanged. It acts just like btnAccept does and changes gbxSchedule.Text. Can anyone help me figure this one? I think it has to do with assigning Accept and Cancel Properties, i'm just not sure how to get started doing it.
Below is the frmMain form code
Public Class frmMain Inherits System.Windows.Forms.Form + Windows Form Designer Generated Code ' Class-level variables Private course1 As String = "" ' To hold the 8:00 - 8:50 course Private course2 As String = "" ' To hold the 9:00 - 8:50 course Private course3 As String = "" ' To hold the 10:00 - 10:50 course Private course4 As String = "" ' To hold the 11:00 - 11:50 course Private course5 As String = "" ' To hold the 12:00 - 12:50 course Private professor1 As String = "" ' To hold the 8:00 - 8:50 professor Private professor2 As String = "" ' To hold the 9:00 - 8:50 professor Private professor3 As String = "" ' To hold the 10:00 - 10:50 professor Private professor4 As String = "" ' To hold the 11:00 - 11:50 professor Private professor5 As String = "" ' To hold the 12:00 - 12:50 professor Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' This procedure adds the selected course ' to the schedule, which is kept in the ' class-level variables. ' Validate the input variables If lstTimeBlocks.SelectedIndex = -1 Then MessageBox.Show("Please Select a Time Block", "Input Error Message") ElseIf cboCourses.Text = "" Then MessageBox.Show("Please Select a Course", "Input Error Message") ElseIf cboProfessors.Text = "" Then MessageBox.Show("Please Select a Professor", "Input Error Message") ' Determine the time block selected and then add ' the course and professor. Else Select Case CStr(lstTimeBlocks.SelectedItem) Case "8:00 - 8:50" AddCourse(course1, professor1) Case "9:00 - 9:50" AddCourse(course2, professor2) Case "10:00 - 10:50" AddCourse(course3, professor3) Case "11:00 - 11:50" AddCourse(course4, professor4) Case "12:00 - 12:50" AddCourse(course5, professor5) End Select End If End Sub Private Sub AddCourse(ByRef course As String, ByRef professor As String) If course <> "" Then MessageBox.Show("This Time Block Already Filled", "Input Error Message") Else course = cboCourses.Text professor = cboProfessors.Text ' Let the user know the course has been added. MessageBox.Show("Course added for the " & _ lstTimeBlocks.SelectedItem & _ " time block.", "Course Added") ' Clear the selected course and professor. cboCourses.Text = "" cboProfessors.Text = "" lstTimeBlocks.SelectedIndex = -1 btnAdd.Enabled = False End If End Sub Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click ' This procedure displays the schedule on an ' instance of the frmSchedule form. Dim scheduleForm As New frmSchedule Dim gbxSchedule As String If frmStudentName.txtStudentName.Text <> "" Then scheduleForm.gbxSchedule.Text = "Schedule for " & frmStudentName.txtStudentName.Text End If ' Copy the course and professor for the ' 8:00 - 8:50 time block to scheduleForm. scheduleForm.lblCourse1.Text = course1 scheduleForm.lblProfessor1.Text = professor1 ' Copy the course and professor for the ' 9:00 - 9:50 time block to scheduleForm. scheduleForm.lblCourse2.Text = course2 scheduleForm.lblProfessor2.Text = professor2 ' Copy the course and professor for the ' 10:00 - 10:50 time block to scheduleForm. scheduleForm.lblCourse3.Text = course3 scheduleForm.lblProfessor3.Text = professor3 ' Copy the course and professor for the ' 11:00 - 11:50 time block to scheduleForm. scheduleForm.lblCourse4.Text = course4 scheduleForm.lblProfessor4.Text = professor4 ' Copy the course and professor for the ' 12:00 - 12:50 time block to scheduleForm. scheduleForm.lblCourse5.Text = course5 scheduleForm.lblProfessor5.Text = professor5 ' Display the schedule form. scheduleForm.ShowDialog() End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click ' This procedure clears the items in the schedule. ' Clear the course names. course1 = "" course2 = "" course3 = "" course4 = "" course5 = "" ' Clear the professor names. professor1 = "" professor2 = "" professor3 = "" professor4 = "" professor5 = "" ' Reset the list box and combo boxes. lstTimeBlocks.SelectedIndex = -1 cboCourses.Text = "" cboProfessors.Text = "" End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click ' End the application with the Close method. ' This allows the Closing event procedure to execute. Me.Close() End Sub Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing ' Confirm that the user wants to quit. If MessageBox.Show("Are you sure you want to quit?", "Confirm", _ MessageBoxButtons.YesNo) = DialogResult.No Then e.Cancel = True ' Do not quit Else e.Cancel = False ' Go ahead and quit End If End Sub Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click ' Validate the input variables If lstTimeBlocks.SelectedIndex = -1 Then MessageBox.Show("Please Select a Time Block", "Input Error Message") ' Determine the time block selected and then add ' the course and professor. Else Select Case CStr(lstTimeBlocks.SelectedItem) Case "8:00 - 8:50" RemoveCourse(course1, professor1) Case "9:00 - 9:50" RemoveCourse(course2, professor2) Case "10:00 - 10:50" RemoveCourse(course3, professor3) Case "11:00 - 11:50" RemoveCourse(course4, professor4) Case "12:00 - 12:50" RemoveCourse(course5, professor5) End Select btnRemove.Enabled = False End If End Sub Private Sub RemoveCourse(ByRef course As String, ByRef professor As String) If course = "" Then MessageBox.Show("This Time Block Not Yet Filled", "Input Error Message") Else course = "" professor = "" ' Let the user know the course has been removed. MessageBox.Show("Course removed for the " & _ lstTimeBlocks.SelectedItem & _ " time block.", "Course Removed") ' Clear the selected course and professor. cboCourses.Text = "" cboProfessors.Text = "" lstTimeBlocks.SelectedIndex = -1 End If End Sub Private Sub lstTimeBlocks_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles lstTimeBlocks.SelectedIndexChanged Select Case CStr(lstTimeBlocks.SelectedItem) Case "8:00 - 8:50" If course1 = String.Empty Then btnAdd.Enabled = True btnRemove.Enabled = False Else btnAdd.Enabled = False btnRemove.Enabled = True End If Case "9:00 - 9:50" If course2 = String.Empty Then btnAdd.Enabled = True btnRemove.Enabled = False Else btnAdd.Enabled = False btnRemove.Enabled = True End If Case "10:00 - 10:50" If course3 = String.Empty Then btnAdd.Enabled = True btnRemove.Enabled = False Else btnAdd.Enabled = False btnRemove.Enabled = True End If Case "11:00 - 11:50" If course4 = String.Empty Then btnAdd.Enabled = True btnRemove.Enabled = False Else btnAdd.Enabled = False btnRemove.Enabled = True End If Case "12:00 - 12:50" If course5 = String.Empty Then btnAdd.Enabled = True btnRemove.Enabled = False Else btnAdd.Enabled = False btnRemove.Enabled = True End If End Select End Sub Private Sub btnEnterStudent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterStudent.Click frmStudentName.ShowDialog() If frmStudentName.txtStudentName.Text <> "" Then frmSchedule.gbxSchedule.Text = "Schedule for " & frmStudentName.txtStudentName.Text gbxSchedule.Text = "Course Information for " & frmStudentName.txtStudentName.Text End If End Sub End Class
And below is the code from frmStudentName form
Public Class frmStudentName Inherits System.Windows.Forms.Form Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click 'Close the Form Me.Close() End Sub Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click 'Close the Form Me.Close() End Sub End Class -
In Topic: Textbox entry on one form to change text output on another form
Posted 11 Apr 2012
Here is a zip file containing the finished product...
ScheduleBuilderStudent.zip to help future coders with similar problems. -
In Topic: Textbox entry on one form to change text output on another form
Posted 11 Apr 2012
DimitriV, on 11 April 2012 - 02:19 PM, said:Glad we could help!
You are a really great guy DimitriV. Especially spending all that time last night helping a complete stranger. If the world was a little more kind and showed a little more grace like that and was not so quick to judge and make fun of everyone who is not exactly like we are, then we would all live in a much better place.
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
DimitriV
10 Apr 2012 - 23:24