Passing variables between forms

C

Chaucer

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.
 
C

Chaucer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top