Hi,
In the program below, C = A+B, and the aim is to delay the calculation
of C until the user asks for C. The boolean mUTD (UpToDate) is used
indicate when Calc() must be run to make the C = A+B calculation before
C is returned to user.
When the Driver program at bottom is run, the behavior is very strange,
the debug statement "in Calc" gets printed several times on entry to the
constructor, and then again several times when T.A = 1 is executed, and
again several times when T.B = 2 is executed (a grand total of 30 times
for the full execution of Driver. When you step through, the debugger
never actually takes you into Calc() -- you just see the "in calc nn"
printed in output window.
I am using Visual Basic.net, version 2003, Windows XP Pro on a Dell.
I am apparently not understanding something about Property?? or ??
Help!!
Public Class TestCls
Private mA As Double
Private mB As Double
Private mC As Double
Private mUTD As Boolean = False
Private Count As Integer = 0
Property A() As Double
Get
Return mA
End Get
Set(ByVal Value As Double)
mA = Value
mUTD = False
End Set
End Property
Property B() As Double
Get
Return mB
End Get
Set(ByVal Value As Double)
mB = Value
mUTD = False
End Set
End Property
ReadOnly Property C() As Double
Get
If Not mUTD Then Calc()
Return mC
End Get
End Property
Public Sub New()
mUTD = False
End Sub
Private Sub Calc()
mUTD = True
mC = mA + mB
Count = Count + 1
Debug.WriteLine ("In Calc " & Count.ToString)
End Sub
End Class
----------------- Driver Program ----
Module TestDrive
Sub Main()
Dim T As New TestCls
Dim xx As Double
T.A = 1
T.B = 2
xx = T.C
End Sub
End Module
Thanks -- Gary 3 1671
* Gary <cr****@montana dsl.net> scripsit: In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C = A+B calculation before C is returned to user.
When the Driver program at bottom is run, the behavior is very strange, the debug statement "in Calc" gets printed several times on entry to the constructor, and then again several times when T.A = 1 is executed, and again several times when T.B = 2 is executed (a grand total of 30 times for the full execution of Driver. When you step through, the debugger never actually takes you into Calc() -- you just see the "in calc nn" printed in output window.
I am using Visual Basic.net, version 2003, Windows XP Pro on a Dell.
I am apparently not understanding something about Property?? or ?? Help!!
Public Class TestCls
Private mA As Double Private mB As Double Private mC As Double Private mUTD As Boolean = False Private Count As Integer = 0
Property A() As Double Get Return mA End Get Set(ByVal Value As Double) mA = Value mUTD = False End Set End Property
Property B() As Double Get Return mB End Get Set(ByVal Value As Double) mB = Value mUTD = False End Set End Property
ReadOnly Property C() As Double Get If Not mUTD Then Calc() Return mC End Get End Property
Public Sub New() mUTD = False End Sub
Private Sub Calc() mUTD = True mC = mA + mB Count = Count + 1 Debug.WriteLine ("In Calc " & Count.ToString) End Sub End Class
----------------- Driver Program ---- Module TestDrive Sub Main() Dim T As New TestCls Dim xx As Double T.A = 1 T.B = 2 xx = T.C End Sub End Module
I don't see any reason why your code should not work. Are you sure
there is no other code in your project and really 'Sub Main' is
executed?
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Gary wrote: Hi,
In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C = A+B calculation before C is returned to user.
When the Driver program at bottom is run, the behavior is very strange, the debug statement "in Calc" gets printed several times on entry to the constructor, and then again several times when T.A = 1 is executed, and again several times when T.B = 2 is executed (a grand total of 30 times for the full execution of Driver. When you step through, the debugger never actually takes you into Calc() -- you just see the "in calc nn" printed in output window.
Do you see this behaviour when you just run the program all through, or when
stepping in the debugger. Because in the first case I can't reproduce it,
Calc() gets called only once when I just run the program without ever
breaking.
In the debugger the results you see might make sense if the 'C' property is
in either the "Autos", "Locals" or "Watch" window, because every time the
debugger evaluates C for display in these windows, Calc() gets called if
mUDC=False. The debugger would indeed not step into Calc() when that
happens.
--
Sven Groot http://unforgiven.bloghorn.com
Hi,
I did indeed have "C" displayed in the "me" window during debug, and
apparently that was the problem, since it works fine when I close the
"me" window, or just run it without debug.
Thanks -- Gary
Gary wrote: Hi,
In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C = A+B calculation before C is returned to user.
When the Driver program at bottom is run, the behavior is very strange, the debug statement "in Calc" gets printed several times on entry to the constructor, and then again several times when T.A = 1 is executed, and again several times when T.B = 2 is executed (a grand total of 30 times for the full execution of Driver. When you step through, the debugger never actually takes you into Calc() -- you just see the "in calc nn" printed in output window.
I am using Visual Basic.net, version 2003, Windows XP Pro on a Dell. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Guido van Rossum |
last post by:
I'm pleased to announce that the Python Software Foundation (PSF) is now
accepting donations from individuals and companies interested in
supporting our mission to improve the Python programming language.
The PSF holds the intellectual property rights for Python and is working
towards building a program to fund future Python development. Your
donation will make a real difference in the quality of Python's future.
For US individuals: ...
|
by: Luigi |
last post by:
I would know what "criteria" is used in box positioning with the
position property.
Here my tries (using IE and Opera):
I have a box with an absolute positioning (properties used: position,
left and top).
I noted that if the reference of this box is the "html" box or the
"body" box, the browser uses the following rules:
|
by: Steve Teeples |
last post by:
Someone introduced me to PropertyGrid last night. It is a great feature for
what I need. A question though. I noticed that when I assign a "TextBox"
control to a property grid the description on each property is shown at the
bottom of the grid. Also, properties are divided into categories.
How can I do this with my own defined objects?
For example: I would like Name to be in one category with a description for
it and Days to be in...
|
by: Bill Coan |
last post by:
NOTE: This was posted earlier to vsnet.vstools.office under a different
subject line but received no response.
I'm having a problem automating Word's Find object from a .NET application,
using late binding.
If I use early binding, my code runs fine on most systems, but it is
vulnerable to a known bug explained here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;292744
|
by: jbeteta |
last post by:
Hello,
I have a problem declaring variables. I need to create an object oRpte
as ReportClass on WebForm1.aspx and be able to use its value on
WebForm2.aspx.
For declaring the property oRpte() on WebForm1.aspx, I use "Public
Property" and I declare variable _oRpte as Friend Shared. That's my
problem. If I don't declare _oRpte as Friend Shared, I can't use
WebForm1.oRpte() on other webpage. If I declare _oRpte as Friend
Shared, I can use...
| |
by: josh |
last post by:
Hi all,
what does it meaning that strange sintax (look at the object :) ?
if I have i.e. array.length I can use array. and is it
IE/Firefox compatible??
|
by: Tom |
last post by:
Can someone please explain the non-working aspect of binding to Width?
See code below.
Thanks !!
-- Tom
===================================================
using System;
using System.Collections.Generic;
|
by: akonsu |
last post by:
hello,
i need to add properties to instances dynamically during run time.
this is because their names are determined by the database contents.
so far i found a way to add methods on demand:
class A(object) :
def __getattr__(self, name) :
if name == 'test' :
def f() : return 'test'
|
by: Simon van Beek |
last post by:
Dear reader,
What can be wrong in my ComboBox, the property "Auto Expand" is set to Yes,
but by typing in the ComboBox it doesn't expand. Is this because the source
of the ComboBox is a query.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |