Setting variable problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a public class setup as follows

Public Class Variables

Shared Property FranFormOpen() As Boolean
Get
Return FranFormOpen
End Get
Set(ByVal Value As Boolean)
FranFormOpen = Value
End Set
End Property
End Class

I can pull the franformopen variable no problem but when I try to set the
value it errors out. Here is the code I am using to try to set the value:

If FranFormOpen.Equals(False) Then
mdifrmFranchise.MdiParent = Me
mdifrmFranchise.Show()
mdifrmFranchise.WindowState = FormWindowState.Maximized
'cmdFranchiseForm.Checked = True
Variables.FranFormOpen = True
'Validation.cmdUncheck(sender, e)
Else
mdifrmFranchise.WindowState = FormWindowState.Maximized
End If

When debuging...and trying to set the variable...it shows "value" as being =
to True but when it gets to "FranFormOpen = Value" it never changes value to
"True" it just goes back to the "Set(ByVal Value As Boolean)" statement and
keeps looping untill it errors out.

What am I doing wrong?

Thank you
 
You're trying to set the property again from within the property. That gives
you a infinite loop

you need an instance variable to store the value in instead¨.

Public Class Variables
Private ffo As Boolean

Shared Property FranFormOpen() As Boolean
Get
Return Me.ffo
End Get
Set(ByVal Value As Boolean)
Me.ffo = Value
End Set
End Property
End Class
 
you need an instance variable to store the value in instead¨.

If I'm not mistaken, a shared property connot access an instance variable.
The variable must be declared Shared as well.
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Back
Top