Textbox entry on one form to change text output on another form

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 3489 Views - Last Post: 11 April 2012 - 07:41 PM Rate Topic: -----

#16 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 09:34 PM

Well, is my placement of the statements correct in the code by any chance?

And did you download the VB zip file that i uploaded with the original post to see if you might be able to get it working?

I really appreciate everything that you tried to do. You are one of the very few ppl that has been willing to help me on this site and it is more greatly appreciated than you know. :) Thank You
Was This Post Helpful? 0
  • +
  • -

#17 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 09:37 PM

That's all right, I'm so sorry. Had this horrible headache :(
I couldn't download the ZIP. I'm on an iPad so unfortunately I have no easy way to get into it. If you are able to, post the actual source code here and I can take a look (I paper code a lot).
Was This Post Helpful? 1
  • +
  • -

#18 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 10:03 PM

Don't be sorry, it's not like its your job to help me. I just greatly appreciate that you are doing it out of the kindness of your heart.

I will post the code from all three forms and label them, will try screen shots of forms too if i'm able.
Was This Post Helpful? 0
  • +
  • -

#19 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 10:26 PM

You should be able to. Just remember, with images you need to click "Include in Post" so they appear within the post.
Was This Post Helpful? 0
  • +
  • -

#20 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 10:50 PM

MAIN FORM CODE

 Public Class frmMain


    ' 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

        ' 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
        Dim StudentForm As New frmStudentName
        StudentForm.ShowDialog()
    End Sub
End Class



SCHEDULE DISPLAY FORM CODE

Public Class frmSchedule

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        ' Close the form.
        Me.Close()
    End Sub
End Class


ENTER NAME FORM CODE (The only code that doesn't work)

Public Class frmStudentName

    Public Property ScheduleName As String
        Get
            Return txtStudentName.Text
        End Get
        Set(ByVal rec As String)
            gbxSchedule.Text = rec
        End Set
    End Property


    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        'Closes the Form
        Me.Close()
    End Sub

    Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click

        'Changes gbxSchedule.Text to Course information for "txtStudentName.Text"
        If txtStudentName.Text <> "" Then
            ScheduleName = "Course Information for " & txtStudentName.Text
            ScheduleName = "Schedule for " & txtStudentName.Text
        End If


        Me.Close()
    End Sub
End Class


i made a word doc with screen shots it wouldnt allow me to upload. PM an email if you want me to send it to you real quick
Was This Post Helpful? 0
  • +
  • -

#21 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 11:20 PM

This will help me help you - could you explain the error to me? Heaps quick?

This could be worth a shot:
If Not txtStudentName = "" Then
gbxScheduleText = "Course Information for: " & txtStudentName.Text & Chr(13) & "Schedule For: " & txtStudentName.Text
End If


Was This Post Helpful? 0
  • +
  • -

#22 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 10 April 2012 - 11:37 PM

I would personally use two properties here, just for code clarity.
Public Property studentName As String
Get
Return txtStudentName.Text
End Get
Set (ByVal value As String)
txtStudentName.Text = value
End Get
End Property
Public Property Schedule As String
Get
Return gbxSchedule.Text
End Get
Set (ByVal value As String)
gbxSchedule.Text = value
End Get
End Property


Was This Post Helpful? 0
  • +
  • -

#23 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 02:16 PM

It took a little trial and error, but with the help of DimitriV I've figured out a solution for this problem and it was amazingly simple.

Instead of calling the main form from the subform, i needed to be calling the subform from the main form. So in the main form I just had to add the following code into the main form to fix it.

 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 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 Walah! The forms that need to be changed, change; and the TextBox on frmStudentName retains the entered name when the form when returned to!

Thanks so much you 2 guys that got me thinking about it a little better and gave me logic ideas. You have been repped appropriately!

-DDK

This post has been edited by daddydonkykong: 11 April 2012 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

#24 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 02:19 PM

Glad we could help! :)
Was This Post Helpful? 1
  • +
  • -

#25 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 02:26 PM

View PostDimitriV, 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.
Was This Post Helpful? 1
  • +
  • -

#26 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 02:56 PM

Here is a zip file containing the finished product...

ScheduleBuilderStudent.zip to help future coders with similar problems.

Attached File(s)


Was This Post Helpful? 1
  • +
  • -

#27 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 04:26 PM

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

Was This Post Helpful? 0
  • +
  • -

#28 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 04:31 PM

Hang on, what? The code for btnCancel and btnAccept is identical!
Was This Post Helpful? 0
  • +
  • -

#29 daddydonkykong  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-March 12

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 07:19 PM

View PostDimitriV, 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

Was This Post Helpful? 0
  • +
  • -

#30 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Textbox entry on one form to change text output on another form

Posted 11 April 2012 - 07:28 PM

So when you close frmStudentName you want it to clear frmMain.gbxSchedule.Text?
Spoiler

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3