Re: Dim scope within an IF
From: Gary Shell (gshell_at_fuse.net)
Date: 06/30/04
- Next message: Cor Ligthert: "Re: Label control border color"
- Previous message: Adriano: "Re: Mouse location"
- In reply to: Rob Teixeira [MVP]: "Re: Dim scope within an IF"
- Next in thread: One Handed Man \( OHM - Terry Burns \): "Re: Dim scope within an IF"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 30 Jun 2004 02:26:20 -0400
Ah, yes. A Clue By Four. Gladly accepted!
Thanks,
Gary
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:%23kmN1RmXEHA.3988@tk2msftngp13.phx.gbl...
> Private Sub btnEditTheClass_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles btnEditTheClass.Click
>
> Dim frm As BaseClassFormName
>
> If RadioButton_BP.Checked Then
> frm = New frmBP_Class
> ElseIf RadioButton_IO.Checked Then
> frm = New frmIO_Class
> End If
>
> ' rest of code goes here
>
>
> -Rob Teixeira [MVP]
>
> "Gary Shell" <gshell@fuse.net> wrote in message
> news:ucIpJMmXEHA.1048@tk2msftngp13.phx.gbl...
> > I have two forms both derived by inheriting the same base form. I have
a
> > third form that needs to instantiate one of those two forms, set some
> > Protected properties on the two forms, display the form, test a property
> of
> > the from when it is closed and then dispose of the instantiated form.
> >
> > The third form has two radio buttons used to determine wich form to
> > instantiate. The folllowing code fails to compile due to the scope of
the
> > DIM statement.
> >
> > Private Sub btnEditTheClass_Click(ByVal sender As System.Object, ByVal e
> As
> > System.EventArgs) Handles btnEditTheClass.Click
> > If RadioButton_BP.Checked Then
> > Dim frm As New frmBP_Class
> > ElseIf RadioButton_IO.Checked Then
> > Dim frm As New frmIO_Class
> > End If
> >
> > 'pass a connection to SQL
> > frm.sqlConnection = SqlConnection1
> > 'pass the TheClass to be edited
> > frm.TheClass = txtTheClass.Text
> > 'set EDIT mode
> > frm.Mode = frm.Modes.EditMode
> > 'show as a MODAL form
> > frm.ShowDialog()
> > 'if the data was updated
> > If frm.DataUpdated = True Then
> > 'display the updated data
> > txtTheClass.Text = frm.TheClass
> > End If
> >
> > 'dispose of the form
> > frm.Dispose()
> > End Sub
> >
> > Because of this I have to resort to the following:
> >
> > Private Sub btnEditTheClass_Click(ByVal sender As System.Object, ByVal e
> As
> > System.EventArgs) Handles btnEditTheClass.Click
> > If RadioButton_BP.Checked Then
> > Dim frm As New frmBP_Class
> > 'pass a connection to SQL
> > frm.sqlConnection = SqlConnection1
> > 'pass the TheClass to be edited
> > frm.TheClass = txtTheClass.Text
> > 'set EDIT mode
> > frm.Mode = frm.Modes.EditMode
> > 'show as a MODAL form
> > frm.ShowDialog()
> > 'if the data was updated
> > If frm.DataUpdated = True Then
> > 'display the updated data
> > txtTheClass.Text = frm.TheClass
> > End If
> > 'dispose of the form
> > frm.Dispose()
> > ElseIf RadioButton_IO.Checked Then
> > Dim frm As New frmIO_Class
> > 'pass a connection to SQL
> > frm.sqlConnection = SqlConnection1
> > 'pass the TheClass to be edited
> > frm.TheClass = txtTheClass.Text
> > 'set EDIT mode
> > frm.Mode = frm.Modes.EditMode
> > 'show as a MODAL form
> > frm.ShowDialog()
> > 'if the data was updated
> > If frm.DataUpdated = True Then
> > 'display the updated data
> > txtTheClass.Text = frm.TheClass
> > End If
> > 'dispose of the form
> > frm.Dispose()
> > End If
> > End Sub
> >
> >
> >
> > YUCH!!!!! That is truly UGLY. But I, for the life of me, can't find any
> > other way to do this. Suggestions? Clue by fours?
> >
> > Thanks,
> >
> > Gary
> >
> >
>
>
- Next message: Cor Ligthert: "Re: Label control border color"
- Previous message: Adriano: "Re: Mouse location"
- In reply to: Rob Teixeira [MVP]: "Re: Dim scope within an IF"
- Next in thread: One Handed Man \( OHM - Terry Burns \): "Re: Dim scope within an IF"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|