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

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

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

#1 daddydonkykong  Icon User is offline

  • New D.I.C Head

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

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

Posted 10 April 2012 - 05:06 PM

I am having trouble getting the Student Name entered in the Student Name Form to change the Text titles of the GroupBox's on the Main Form and Schedule Form. I understand the logic of what needs to be done to some extent, but I am having trouble coming up with the correct coding.

Below is a snippet of the Student Name Form code that I tried most recently just to see if I could get any change to happen to the other 2 Forms when the Accept Name button was clicked. As of yet, I cannot get a change to happen at all in the groupboxes of the other Forms.

Public Class frmStudentName
    Dim mainForm As New frmMain
    Dim scheduleForm As New frmSchedule

    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
            mainForm.gbxSchedule.Text = "Course Information for  " And
            scheduleForm.gbxSchedule.Text = "Schedule for  "
        End If


        Me.Close()
    End Sub
End Class


ANY HELP WOULD BE GREATLY APPRECIATED!!! AND MODS, PLS JUST LET ME GET SOME HELP HERE WITHOUT SHUTTING ME DOWN REPEATEDLY. I HAVE NOWHERE ELSE TO TURN AT THIS POINT OR I WOULDN'T BE HERE ASKING FOR HELP. THERE IS NO TUTOR AVAILABLE FOR THIS CLASS AND I ACTUALLY WANT TO LEARN IT, NOT JUST HAVE IT DONE FOR ME. I APOLOGIZE IF IT CAME OFF THAT WAY IN THE PREVIOUS THREAD.

Thank you,
ALL CAPS

[quote name='daddydonkykong' date='10 April 2012 - 05:03 PM' timestamp='1334102611' post='1597134']
Sorry couldn't find the edit button to add the 
to the bottom i forgot...

Public Class frmStudentName
    Dim mainForm As New frmMain
    Dim scheduleForm As New frmSchedule

    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
            mainForm.gbxSchedule.Text = "Course Information for  " And
            scheduleForm.gbxSchedule.Text = "Schedule for  "
        End If


        Me.Close()
    End Sub
End Class

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Textbox entry on one form to change text output on another form

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 137
  • View blog
  • Posts: 829
  • Joined: 21-December 11

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

Posted 10 April 2012 - 05:14 PM

If txtStudentName.Text = "" Then
mainForm.gbxSchedule.Text = "Course Information for " And
scheduleForm.gbxSchedule.Text = "Schedule for "
End If


your mainForm.gbxSchedule.Text and scheduleForm.gbxSchedule.Text will change only if txtStudentName.Text is empty.

do you mean something like this?
If Not txtStudentName.Text = "" Then
mainForm.gbxSchedule.Text = "Course Information for " And
scheduleForm.gbxSchedule.Text = "Schedule for "
End If


If Not txtStudentName.Text = "" Then
mainForm.gbxSchedule.Text = "Course Information for " & txtStudentName.Text
scheduleForm.gbxSchedule.Text = "Schedule for " & txtStudentName.Text
End If


Was This Post Helpful? 1
  • +
  • -

#3 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 - 05:19 PM

What i really want it to say is...

if there is "something" in txtStudentName.Text Then
change gbxSchedule.Text on both forms To what i have in the quotes + whats typed into txtStudentName.Text
Was This Post Helpful? 0
  • +
  • -

#4 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 137
  • View blog
  • Posts: 829
  • Joined: 21-December 11

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

Posted 10 April 2012 - 05:26 PM

yes that's it. If txtStudentName.Text is not empty then ...
If Not txtStudentName.Text = "" Then
'change gbxSchedule.Text on both forms
End If


or

If txtStudentName.Text <> "" Then
'change gbxSchedule.Text on both forms
End If

Was This Post Helpful? 1
  • +
  • -

#5 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 - 05:27 PM

The If Not statement will still not effect the groupbox's on the other 2 forms. I think I am missing a declaration or variable somewhere that is keeping the information from being sent to the other 2 forms, but I am very inexperienced at this and do not see what I am missing...
Was This Post Helpful? 0
  • +
  • -

#6 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 137
  • View blog
  • Posts: 829
  • Joined: 21-December 11

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

Posted 10 April 2012 - 05:40 PM

so you say you have 3 forms.
first is mainForm
second is scheduleForm
third form is frmStudentName with txtStudentName.Text?

try put this in your button and tell what happens.
mainForm.gbxSchedule.Text = "new text"
scheduleForm.gbxSchedule.Text = "new text"

Was This Post Helpful? 1
  • +
  • -

#7 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

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

Posted 10 April 2012 - 05:53 PM

Try using a Public Property
Public Property thegg As String
Get
Return nameBox.Text
End Get
Set (ByVal rec As String)
nameBox.Text = rec
End Set
End Property


Try that, alter it a bit, see what you get :)
Was This Post Helpful? 1
  • +
  • -

#8 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 - 07:11 PM

View PostDimitriV, on 10 April 2012 - 05:53 PM, said:

Try using a Public Property
Public Property thegg As String
Get
Return nameBox.Text
End Get
Set (ByVal rec As String)
nameBox.Text = rec
End Set
End Property


Try that, alter it a bit, see what you get :)


I have a feeling that this is a really stupid question, but where exactly would the modified version of this go in my logic and what would need to come out in its place?
Was This Post Helpful? 0
  • +
  • -

#9 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

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

Posted 10 April 2012 - 07:13 PM

Not stupid. Not at all.
In the get statement where it says return suchandsuch replace nameBox with the name of the TextBox you wish to use. In the set, do the same.
Was This Post Helpful? 1
  • +
  • -

#10 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 - 07:41 PM

View PostDimitriV, on 10 April 2012 - 07:13 PM, said:

Not stupid. Not at all.
In the get statement where it says return suchandsuch replace nameBox with the name of the TextBox you wish to use. In the set, do the same.



That answers a different question, but what I was asking is....

where does this code \/

'this look right?

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


go in the order of things within this code, OR does it replace it? \/

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
mainForm.gbxSchedule.Text = "Course Information for " & txtStudentName.Text
scheduleForm.gbxSchedule.Text = "Schedule for " & txtStudentName.Text
End If


And does Thegg stay? or replaced?
Was This Post Helpful? 0
  • +
  • -

#11 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

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

Posted 10 April 2012 - 07:45 PM

I just named it thegg. Does it look right to you? Do you want to return the value of 1 text box and set another with the same property? Usage:
MainForm.thegg = "blaarh"

Was This Post Helpful? 1
  • +
  • -

#12 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 - 08:02 PM

View PostDimitriV, on 10 April 2012 - 07:45 PM, said:

I just named it thegg. Does it look right to you? Do you want to return the value of 1 text box and set another with the same property? Usage:
MainForm.thegg = "blaarh"


Well yes, it seems right to me. To me your logic says, get from one place and set what you get in another place. But its only setting in one place, so i'm not sure if i need to do another one or add the other instance, but they are named the same thing just on different forms. So this being "Public class" does that mean that it applies to all forms?
Was This Post Helpful? 0
  • +
  • -

#13 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

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

Posted 10 April 2012 - 08:13 PM

Being public is just the accessibility level of the object. This is an interesting page to do with that: http://www.techrepub...s-modifiers/513
Was This Post Helpful? 1
  • +
  • -

#14 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 - 08:18 PM

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


this is what i tried to change it to but still, no dice. I tried a few other ways, like leaving the Dim statements for mainForm and scheduleForm, but then when I combine the "ScheduleName" with them i get errors saying schedulename is not found on those forms...
Was This Post Helpful? 0
  • +
  • -

#15 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

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

Posted 10 April 2012 - 08:39 PM

I don't know what to suggest any more, I'm so sorry.
Was This Post Helpful? 1
  • +
  • -

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