Your property is recursive. Instead of setting a private variable, you are
just assigning the value to the property itself - which just calls it over
and over again.
Your GET btw, could only return a boolean of whether or not the property is
equal to itself. Not only will this recursively call itself until you get a
StackOverflowException, but the return of that would actually be a Boolean
(if it was capable of ever ending), and not a string at all. Which means you
should turn Option Strict On.
You need to define your property like this:
private _myProp As String
Public Property MyProperty() As String
Get
Return _myProp
End Get
Set(ByVal Value As String)
_myProp = Value
End Set
End Property
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:B7**********************************@microsof t.com...
My first simple attempt at using a property. and I get an exception "An
unhandled exception of type 'System.StackOverflowException' occurred in
BalanceOmatic.exe" on line xxx. I have included the property code and
the
button event used to set and call the property value. Any help greatly
appreciated.
What am I missing?
Thanks
Mike
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
User.MyProperty = "Property Set"
MsgBox(User.MyProperty & " User.MyProperty")
End Sub
Public Property MyProperty() As String
Get
MyProperty = MyProperty
End Get
Set(ByVal Value As String)
Line xxx MyProperty = Value
End Set
End Property