Question : vb.net check if form is open

hello there,
I have form1 and form2.. I have a textbox in each form and a button..
I would like to set a if in the button to check if form2 is open to change the textbox text to test..
how can I do that?

Answer : vb.net check if form is open

Play with this...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        f2.Show()
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For Each frm As Form In Application.OpenForms
            If TypeOf frm Is Form2 Then
                Dim f2 As Form2 = CType(frm, Form2)
                f2.TextBox1.Text = "Testing..."
            End If
        Next
    End Sub
 
End Class
Random Solutions  
 
programming4us programming4us