Referring to the code that you pointed out where:
Private Sub Button1_Click(...) ...
Dim f As New Form2()
If f.ShowDialog(Me) = DialogResult.OK Then
MsgBox(f.Date.ToString())
Else
MsgBox("Cancelled")
End If
End Sub
I have one point of confusion, on page 57 of Microsoft's Developing
Windows-based applications with Visual Basic .net (2nd ed) they indicate
that "you can call the Form.Close method to close the form and remove it
from memory. This method closes all resources contained within the form and
marks them for garbage collection. Once you have called form.close, you
cannot call form.show to make the form visible again because the resources
for the form are no longer available."
Therefore, in form 2 where:
Private Sub btnOK_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles btnOK.Click
Me.DialogResult = DialogResult.OK
Me.Close()
End Sub
the close method is called. The confusion I have is that if I were expecting
that the resources from that form are unavailable that I would not be able
to get the result that was shown in the example. Granted GC happens at
irregular intervals, so there is a time when it is available, but is the
reason that one can consistently expect the example code to work because
button1 controls the memory space for the form variable and it isn't until
button1's variables leave scope that those variables are actually marked for
GC and are not available?
Thanks
want
a 1, 2, or 3 to come back depending on the user choice