G
Guest
I have a menu form that has a number of buttons that each launch a different
form. The syntax is the same except for the form name is different. How do
create a common function that launches a new form that excepts the form name
as an argument?
My current syntax:
Private Sub btnNewSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewSearch.Click
Dim applicantion As New applicantion
applicantion.MdiParent = Me.MdiParent
applicantion.Show()
End Sub
Private Sub btnDispute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDispute.Click
Dim dispute As New dispute
dispute.MdiParent = Me.MdiParent
dispute.Show()
End Sub
Private Sub btnClientAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClientAdd.Click
Dim clientAdd As New clientAdd
clientAdd.MdiParent = Me.MdiParent
clientAdd.Show()
End Sub
I would like to create a VB function that works like this:
Private Sub launchForm(ByVal formName as string)
Dim form As New formName
form .MdiParent = Me.MdiParent
form .Show()
Sub
But the syntax wouldn't work because formName is not provided until Runtime.
Any thoughts? Thanks.
form. The syntax is the same except for the form name is different. How do
create a common function that launches a new form that excepts the form name
as an argument?
My current syntax:
Private Sub btnNewSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewSearch.Click
Dim applicantion As New applicantion
applicantion.MdiParent = Me.MdiParent
applicantion.Show()
End Sub
Private Sub btnDispute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDispute.Click
Dim dispute As New dispute
dispute.MdiParent = Me.MdiParent
dispute.Show()
End Sub
Private Sub btnClientAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClientAdd.Click
Dim clientAdd As New clientAdd
clientAdd.MdiParent = Me.MdiParent
clientAdd.Show()
End Sub
I would like to create a VB function that works like this:
Private Sub launchForm(ByVal formName as string)
Dim form As New formName
form .MdiParent = Me.MdiParent
form .Show()
Sub
But the syntax wouldn't work because formName is not provided until Runtime.
Any thoughts? Thanks.