title: Visual Basic 2012: Passing variable from one form to another
body: <p>I have two forms, the main (Main.vb) program window and a pop-up that appears when the program is started (getInitialBalance.vb). I need to get a value entered into the PopUp window from the popup window to the Main program. The relevant code is shown below:</p>
  
  <h2>getinitialbalance.vb</h2>
  
  <pre><code>Public Class GetInitialBalance
      Public initialBalance As Integer
  
      Private Sub btnApplyInitialBal_Click(sender As Object, e As EventArgs) Handles btnApplyInitialBal.Click
          Dim textinput As Integer = txtInitialBalance.Text
          initialBalance = textinput
          Me.Close()
      End Sub
  End Class
  </code></pre>
  
  <h2>Main.vb</h2>
  
  <pre><code>Public Class Main
      Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          GetInitialBalance.ShowDialog()
      End Sub
  
      Dim localInitialBalance As Integer = GetInitialBalance.initialBalance
  
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          MsgBox(localInitialBalance)
      End Sub
  End Class
  </code></pre>