Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Passing variables between forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chaucer - 09 Mar 2006 17:39 GMT
Trying to pass variables between 2 forms.  I think I have it all set up
correctly but I'm not getting my changes from form2 back into form1.
Well, before I get into that, here is what I am trying to do.  Load
form1 with some default config values.  When you want to change those
values, you load form2 and make your changes.  These values need to be
imported back into form 1 for use.  I'm not getting any build errors so
I think it's just my logic that is messed up somewhere.

Here's a portion of my code.

FORM1:

Public Class frmConfigBuilder
   Inherits Form
   'For form 2 to show
   Dim frmTwo As New frmExcelColumns

   Dim RowStart As Integer

   Public Property passRowStart() As Integer
       Get
           Return RowStart
       End Get
       Set(ByVal Value As Integer)
           RowStart = Value
       End Set
   End Property

  Private Sub mnuExcelColumns_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuExcelColumns.Click
       frmTwo.Show()

  End Sub
End Class

FORM2:

   Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
       Dim frmOne As New frmConfigBuilder
       frmOne.passRowStart = txtRowStart.Text
       Me.Hide()
   End Sub

Any help would be greatly appreciated.
Thanks in advance.
Chaucer - 09 Mar 2006 19:43 GMT
I figured it out.  I had my stuff backwards... :S  I knew it was some
stupid logic problem.  Here's what I have now.

FORM1:

Public Class frmConfigBuilder
   Inherits Form
   'For form 2 to show
   Dim frmTwo As New frmExcelColumns

   Dim RowStart As Integer

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCreate.Click
      Me.RowStart = frmTwo.passRowStart
   End Sub

   Private Sub mnuExcelColumns_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuExcelColumns.Click
       frmTwo.Show()

   End Sub

End Class

FORM2:

Public Class frmExcelColumns
   Inherits System.Windows.Forms.Form

   Dim RowStart As Integer = 14

   Public Property passRowStart() As Integer
       Get
           Return RowStart
       End Get
       Set(ByVal Value As Integer)
           RowStart = Value
       End Set
   End Property

   Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
       Me.RowStart = txtRowStart.Text
       Me.Hide()
   End Sub

End Class

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.