Reputation: 175
I have narrowed my problem to this simple case, but can't seem to find what's going on:
In addition, when entering VisibleChanged
, Form2 will stop with a MsgBox
The code follows.
Now the Expected behavior, when clicking on button would be
all this does happend, but then,
Any idea why?
here's the code:
Public Class Form1
Private Sub ButtonGO_Click(sender As Object, e As EventArgs) Handles ButtonGO.Click
Me.Hide()
Form2.Show()
End Sub
End Class
and also
Public Class Form2
Dim calls As Integer = 0
Private Sub Form2_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
calls += 1
MsgBox("calling : " & calls & " / Me.Visible : " & Me.Visible)
If Me.Visible Then
Me.Hide()
Form1.Show()
End If
End Sub
End Class
Upvotes: 3
Views: 93
Reputation: 175
Ok, so in order to close : thanks for your answers, they tell what to do for a "full" VB coder.
As for my students, i.e. people who just use drag-n-drop-VB, the solution is to check conditions in Form1 and then only call Form2 when it will show up.
Note : This might seem trivial, but it may not be compliant with the "encapsulation" idea. That is what brought this issue up in the first place in my case.
Upvotes: 0