I have a select case which opens various forms as ShowDialog. Notice
the repetition;

\\
Case "btnManageJobs"
Dim f As New f010Jobs
Me.Visible = False
f.ShowDialog()
Me.Visible = True

Case "btnSeqOfOper"
Dim f As New f050SqOO
Me.Visible = False
f.ShowDialog()
Me.Visible = True

Case "btnViewer"
Dim f As New f060View
Me.Visible = False
f.ShowDialog()
Me.Visible = True
//

How can I take the code...

\\
Me.Visible = False
f.ShowDialog()
Me.Visible = True
//

... and put it after the select case block?

IOW is there any way to declaire "f" before the select case block and
give it the form name within the select case and then run the
"f.ShowDialog" after the block.

Orrrrr is there a simpler way to do this?

thank you,
dbuchanan

Re: How do I simplify this code by Tim

Tim
Sat Nov 12 16:03:52 CST 2005

You could do that in the following way...

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim f As Form = Nothing

Select Case True
Case sender Is Button1
f = New Form2
Case sender Is Button2
f = New Form3
End Select

If (Not f Is Nothing) Then
Me.Visible = False
f.ShowDialog()
Me.Visible = True
End If

End Sub

--
Tim Wilson
.NET Compact Framework MVP

"dbuchanan" <dbuchanan52@hotmail.com> wrote in message
news:1131825110.641332.236860@o13g2000cwo.googlegroups.com...
> I have a select case which opens various forms as ShowDialog. Notice
> the repetition;
>
> \\
> Case "btnManageJobs"
> Dim f As New f010Jobs
> Me.Visible = False
> f.ShowDialog()
> Me.Visible = True
>
> Case "btnSeqOfOper"
> Dim f As New f050SqOO
> Me.Visible = False
> f.ShowDialog()
> Me.Visible = True
>
> Case "btnViewer"
> Dim f As New f060View
> Me.Visible = False
> f.ShowDialog()
> Me.Visible = True
> //
>
> How can I take the code...
>
> \\
> Me.Visible = False
> f.ShowDialog()
> Me.Visible = True
> //
>
> ... and put it after the select case block?
>
> IOW is there any way to declaire "f" before the select case block and
> give it the form name within the select case and then run the
> "f.ShowDialog" after the block.
>
> Orrrrr is there a simpler way to do this?
>
> thank you,
> dbuchanan
>