How to Pass a button and form to a method

Joined
Aug 28, 2008
Messages
13
Programming Experience
Beginner
Hi friend
I am having a problem with passing a button and form to a method.
Let me explain detail.

when i click a button it will send some this button and a form to a method. The method then do some job. like

Private Sub btnEducationNFinance_Click(object sender, EventArgs e)
showForm(button1, i , formName); //Any Wrong ?
End Sub

private Sub ShowForm(.......) // I need this declearation
form1 frm = new formName);
frm.show();
End Sub

Thanks:)
 
Last edited:
VB.Net would be:
VB.NET:
Private Sub ShowForm(byval bt As Button, byval frm As Form)
'stuff......
End Sub
Then called like:
VB.NET:
ShowForm(button1, form2)
In the sub use the values bt.- and frm.- and it will reference the objects you specified when you called it. Hope you can convert it easily enough.
 
thanks newGuy

But Error

showForm(i btn, formName)
'formname' is a 'type' but is used like a 'variable'
and

formName frm = new formName();
The type or namespace name 'formShow' could not be found (are you missing a using directive or an assembly reference?

does not work
 
Last edited:
VB.NET:
 Private Sub NewForm(ByVal btn As Button, ByVal frm As Form)
        btn.Visible = False
        frm = New Form1
        frm.Show()
    End Sub
then
VB.NET:
  NewForm(Button2, Me)
 
Last edited:
Back
Top