-1

I'm writing a program with many forms and many global variables.

I defined my variable in a module and in one form (form2) I assigned a value to them. Then, by clicking the "Calculate" button, I jump to in another form (form3) and I use my variable to extract results.

I have a problem with my back key. My code for backing is:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.Close()
    Form2.Show()
End Sub

When I go back to form2, my text boxes have the past values (as I need them to) but when I change the value and click on the calculate button again, there is no change in my result because my variable doesn't change. Please help me what should I do?

ehsan to
  • 9
  • 3
  • 1
    Please add some code to the question... What is the `Form2_Load` code? What's the code in the calculate button click method? I think it's worth you reading http://stackoverflow.com/help/how-to-ask before asking again. – David Dec 07 '16 at 09:34
  • Without seeing the relevant code, I'm guessing that you're either declaring form3 outside of the click event for the calculate button or using the default instance.

    If possible, declare and show it inside the calculate button click event handler and pass the parameters to it inside the calculate button click event handler.

    This way, each time the form is close and the calculate button click event handler completes, form3 is disposed and next time you click the calculate button, the form is recreated and receives new values.
    – David Wilson Dec 07 '16 at 10:25
  • you just try to refresh your object and form. – BALA s Dec 07 '16 at 11:42

1 Answers1

0

tanx. actually i solved it with this code

    Me.Hide()
    Dim frm2 As New Form2
    frm2.Visible = True

the key code was .visible

ehsan to
  • 9
  • 3