One variable can call many form

  • Thread starter Thread starter khokimfang
  • Start date Start date
K

khokimfang

Hi All,

I want to ask how to call form with only one variable in VB.Net.
I have 3 form (Form1, Form2 and Form3) and 1 module.
in the module i want to declare public variable to call form for ex:
Public frm as .....

In the Form1 i have two button (btnForm2 and btn Form3) and one
Function.
Public Function callForm(FormName as String)
frm=..............
frm.show()
frm.txtNameForm.text=FormName
End Function

In the Form2 i have one textbox (txtNameForm)
In the Form3 i have one textbox(txtnameForm)

So, if I click btnForm2 it will "Call callForm("Form2"), Form2 will
displayed and txtnameForm="Form2".
And If I click btnForm3 it will "Call callForm("Form3"), Form3 will
displayed and txtnameForm="Form3".

So can anybody help me how to declare the frm variable so it can call
many form.

Thanks b4
 
try something along these lines

Private frm As Form

Private Sub Button1_Click(...)

frm = New Form2
frm.Show()

End Sub

Private Button2_Click(...)

frm = New Form3
frm.Show()

End Sub


hope that helps
 
Thanks, it works in Windows Application. But when i try it in Smart
Device Application, it's error. Is .Net Framework not support that in
Smart Device?

Thanks
 
Back
Top