execute public sub on other form

  • Thread starter Thread starter Sven
  • Start date Start date
S

Sven

i have 2 forms:

form1 with 1 button

Dim f As New Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f.Show()

End Sub

Public Sub sven()

MsgBox("dd")

End Sub



form2 with 1 button

Dim f As Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f.sven()

Me.Hide()

End Sub



Why does this not work? how can I execute sven by clicking button1 on form2?
 
* "Sven said:
i have 2 forms:

form1 with 1 button

Dim f As New Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

f.Show()

End Sub

Public Sub sven()

MsgBox("dd")

End Sub

Add a public property of type 'Form1' to Form2 and pass a reference to
your instance of 'Form1' to 'Form2' by setting this property to 'Me' in
'Form1'. Then you can access the instance of 'Form1' from 'Form2'.
 
Back
Top