vishalmarya
Programmer
- Aug 19, 2001
- 28
i have a form ( form2) , which can be called by any other form. all other forms have a sub test. depending on which form has called form2 , sub test is executed ( the procedure of the calling form ).
the code below works fine in vb6 , but equivalent vb.net code got problems.
==============
Vb 6 code :
form1 :
Private Sub Button1_Click
Dim ofrm As New Form2
set ofrm.senderfrm = Me
ofrm.Show()
end sub
public sub test()
msgbox "this is test"
end sub
-----------------------------
form2
''' declaration section
Public senderfrm As form
Private Sub Button1_Click
senderfrm.test()
end sub
=======================
vb.net code
form1 :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ofrm As New Form2
ofrm.senderfrm = Me
ofrm.Show()
End Sub
Public Sub test()
MsgBox("this is test")
End Sub
-----------------
form 2 :
''' declaration section
Public senderfrm As System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
senderfrm.test()
' ERROR " test not a member "
End Sub