From: C. Kevin Provance on
I discovered a hell of a thing:

I have this is a standard module:

Public Property Get LoadPercent() As Long

mlLoadPercent = mlLoadPercent + 6

LoadPercent = mlLoadPercent

End Property

mlLoadPercent is a module level variable.

When I call LoadPercent from anywhere within my code, break the code on the
line that calls LoadPercent and mouseover the LoadPercent, which displays
it's current value, the value displayed in the tooltip incrases with each
mouseover. How's that for messed up!
From: Karl E. Peterson on
C. Kevin Provance laid this down on his screen :
> I discovered a hell of a thing:
>
> I have this is a standard module:
>
> Public Property Get LoadPercent() As Long
>
> mlLoadPercent = mlLoadPercent + 6
>
> LoadPercent = mlLoadPercent
>
> End Property
>
> mlLoadPercent is a module level variable.
>
> When I call LoadPercent from anywhere within my code, break the code on the
> line that calls LoadPercent and mouseover the LoadPercent, which displays
> it's current value, the value displayed in the tooltip incrases with each
> mouseover. How's that for messed up!

Makes sense. Each time you wave the mouse over, the property procedure
is called to retrieve the value. Since simply calling the procedure
increments it, well...

Put it in a class, and make the class persistent, same thing...

Private Sub Command1_Click()
Dim c As Class1
Set c = New Class1
Debug.Print c.LoadPercent
End Sub

I guess it's a pretty good example why you wouldn't want the property
procedure calculating a new value based on anything but external
criteria (memory load, etc)?

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Charlie on
Bug or feature? Well that depends... If I wrote it it's a bug, if my boss
wrote it it's a feature! ;)

"C. Kevin Provance" wrote:

> I discovered a hell of a thing:
>
> I have this is a standard module:
>
> Public Property Get LoadPercent() As Long
>
> mlLoadPercent = mlLoadPercent + 6
>
> LoadPercent = mlLoadPercent
>
> End Property
>
> mlLoadPercent is a module level variable.
>
> When I call LoadPercent from anywhere within my code, break the code on the
> line that calls LoadPercent and mouseover the LoadPercent, which displays
> it's current value, the value displayed in the tooltip incrases with each
> mouseover. How's that for messed up!
>
From: Jeff Johnson on
"C. Kevin Provance" <*@*.*> wrote in message
news:huk5ov$7cs$1(a)news.eternal-september.org...

>I discovered a hell of a thing:
>
> I have this is a standard module:
>
> Public Property Get LoadPercent() As Long
>
> mlLoadPercent = mlLoadPercent + 6
>
> LoadPercent = mlLoadPercent
>
> End Property
>
> mlLoadPercent is a module level variable.
>
> When I call LoadPercent from anywhere within my code, break the code on
> the
> line that calls LoadPercent and mouseover the LoadPercent, which displays
> it's current value, the value displayed in the tooltip incrases with each
> mouseover. How's that for messed up!

Sounds like what you just "discovered" is the concept of "side effects." And
now you know why they're considered a bad thing.


From: Karl E. Peterson on
Jeff Johnson explained :
> "C. Kevin Provance" <*@*.*> wrote in message
> news:huk5ov$7cs$1(a)news.eternal-september.org...
>
>>I discovered a hell of a thing:
>>
>> I have this is a standard module:
>>
>> Public Property Get LoadPercent() As Long
>>
>> mlLoadPercent = mlLoadPercent + 6
>>
>> LoadPercent = mlLoadPercent
>>
>> End Property
>>
>> mlLoadPercent is a module level variable.
>>
>> When I call LoadPercent from anywhere within my code, break the code on the
>> line that calls LoadPercent and mouseover the LoadPercent, which displays
>> it's current value, the value displayed in the tooltip incrases with each
>> mouseover. How's that for messed up!
>
> Sounds like what you just "discovered" is the concept of "side effects." And
> now you know why they're considered a bad thing.

I'd disagree. It's *cool* to be able to hover over something to get
its value. But you need to know what it is you're hovering over. If
it's a variable, that's what you get. If it's, in essence, a function
then you need to expect (or deduce) that the function has to execute to
return a value. What's interesting, though, is the "in essence" part
of this. You don't get the retval from an actual function by hovering
over it. That only happens with object properties. It's a good
heads-up! I never really thought about how that'd all play out until
it was posted here.

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org