Any shortcut to passing a form as an argument
I was hoping that vs 2005 would ease the problem of passing a form as an argument over vs 2003. Looks like not. It is very cumbersome to overload a procedure for each form, so much so that there's no reason to do it.
sub XXX(frm as New Form1) Sub XXX(frm as New Form2) |
etc.
It's easier to repeat the code within the form. Is there a workaround
dennist

Any shortcut to passing a form as an argument?
mike todd
Nope, that's the first thing I tried. Just tried again. Intellisense doesn't show any of the specific form's members. I just tried it again. If I type one in it produces an error.
dennist
wilsilvermite
dennist
Nevil
Thanks Joe,
I just tried it. There was a wiggly line under New, which said New is not valid in this context.
dennist
jungleKing
millerfjtp
Sub XXX(frm as new Form)
Joe
urraca
Public Shared Sub MyMethod(ByRef myForm As Form)
Dim tempForm As Form = Nothing
If (myForm.GetType().Name = "Form1") Then
MessageBox.Show("Form1")
tempForm = New Form1()
tempForm.ShowDialog()
ElseIf (myForm.GetType().Name = "Form2") Then
MessageBox.Show("Form2")
tempForm = New Form2()
tempForm.ShowDialog()
ElseIf (myForm.GetType().Name = "Form3") Then
MessageBox.Show("Form3")
tempForm = New Form3()
tempForm.ShowDialog()
Else
MessageBox.Show("Invalid Form")
End If
End Sub
You can use this method with the following call:
MyMethod(New Form3)
The_Gangster
Oi, ve voi. Thank you very much.
I was hoping studio 2005 would have had a shortcut. Looks like it doesn't.
Thanks again.
dennist
jclausius
I'm a little confused, why to you want to pass so many Form instances to this one form