More advanced question - how to form subroutines or classes which Ican use on several forms

A

Armin Zingler

Am 04.08.2010 15:13, schrieb Armin Zingler:
At the end, I once more point out to the fact that IDisposable is about
*determinstic* clean-up of *unmanaged* ressources and there is zero relation
to the *non-deterministic* work of the GC.

I wanted to keep it simple, but I must correct this!

In the clean-up method, we must distinguish between deterministic
and non-deterministic clean-up. The former is done by explicitly calling
the Dispose method from code. The latter is done by a call from the Finalize
method.

That means:
- In a deterministic clean-up, the unmanaged ressources must
be freed *and* references to managed ressources (for example, large arrays)
can be removed. I write "can", but in a Dispose method it's assumable that
the object won't be used anymore, so replace "can" by "should".

Of course, before removing these references, their Dispose method should
be called also if the object is the owner of the objects, so we have a
cascade-like clean-up.

- In a non-deterministic clean-up, only unmanaged ressources can be freed.
Managed ressources *must not* be accessed because they might have already been
destroyed by the GC.


What I wanted to say with my (now corrected) sentence was that the GC
has nothing to do with the IDisposable pattern.
 
C

C

Am 04.08.2010 10:11, schrieb C:





No, this overwrites the passed graphics object! You'd better remove the line.

I have now removed this, and corrected a small logic error in the If
statement (now If yy3 > 90 AndAlso yy3 < 390 Then). Now it draws the
lines also.

Next, I will put a part of the plotting routine code in the Module,
which will be used by several other Forms.
Why should you pass frmImage? You don't need it inside the method (after removing
the line as written above).

Yes, I understand. I removed it.
Code:
If you draw "frmImage" in the paint event, it should work. Does it now?[/QUOTE][/QUOTE]
[QUOTE]
It does not. I have the following in Paint.[/QUOTE]
[QUOTE]
    Private Sub Form3_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint[/QUOTE]
[QUOTE]
        Dim rect As New Rectangle(100, 90, 600, 300)
        e.Graphics.FillRectangle(Brushes.LightCyan, rect)
        e.Graphics.DrawImage(frmImage, 0, 0)
        e.Graphics.DrawRectangle(Pens.LightGreen, rect)[/QUOTE]
[QUOTE]
    End Sub[/QUOTE]

I don't see a flaw in your code. Don't know why it doesn't work.[/QUOTE]

The If statement was preventing lines from being drawn. The ranges
were wrong.
[QUOTE]
Q: Do you see anything at all when frmImage is painted? Is it a
black rectangle? Do you only see the lines that you draw
directly in cmdPlot_Click (in color Pens.Firebrick), or do
you only not see the lines drawn in draw_h_lines?[/QUOTE]

It was showing me the curve plotted from cmdPlot_Click in
Pens.Firebrick.
[QUOTE]
There is nothing more basic than minding the data types.
You are also doing yourself a favor if you put the right code in the right
classes, right from the start. It's not advanced, it's fundamental.[/QUOTE]

I will be more than glad to learn this. My concept of classes is still
hazy. I will learn by trial and error, and by reading, and will also
ask here.

Thanks. Now I can start another thread about a tiny problem which is
beyond me.
 
A

Armin Zingler

Am 04.08.2010 15:43, schrieb C:
I will be more than glad to learn this. My concept of classes is still
hazy.

Then you are more than 12 years (when VB6 came out) behind the schedule. ;-)
Classes have been an even older concept.
I will learn by trial and error, and by reading, and will also
ask here.

You're welcome! :)

But be aware that Microsoft cancelled their public news server (microsoft.public.*
groups). It's unknown if and when your news server will delete this newsgroup.
I hope mine will keep it as long as possible (forever would be nice...)
 
C

C

Am 04.08.2010 15:43, schrieb C:


Then you are more than 12 years (when VB6 came out) behind the schedule. ;-)
Classes have been an even older concept.

The trouble is that I am not a programmer, so I cannot spend a lot of
time learning all the new things that come up in programming. I have
read about classes long back, but did not feel compelled to use them
anywhere. Now is a good time to familiarise myself with them.
You're welcome! :)

But be aware that Microsoft cancelled their public news server (microsoft.public.*
groups). It's unknown if and when your news server will delete this newsgroup.
I hope mine will keep it as long as possible (forever would be nice...)

Google maintains these groups in its own way, and they may not
necessarily delete a newsgroup given up by someone else. See
groups.google.com. They tend to keep all the posts forever, and if
someone wants their post to be removed, it is a big problem to get
Google to listen to you. Even if this disappears, something similar
will most likely come up to replace it quickly.
 
A

Armin Zingler

Am 04.08.2010 20:52, schrieb C:
The trouble is that I am not a programmer, so I cannot spend a lot of
time learning all the new things that come up in programming. I have
read about classes long back, but did not feel compelled to use them
anywhere. Now is a good time to familiarise myself with them.


Yeah, nowadays it's more difficult to learn programming than it was
several years ago (IMO). I mean, you have to learn much more before you can
write your first line of code (as I prefer not to bring forward learning
content).
 
J

J.B. Moreno

Armin Zingler said:
But be aware that Microsoft cancelled their public news server
(microsoft.public.*
groups). It's unknown if and when your news server will delete this newsgroup.
I hope mine will keep it as long as possible (forever would be nice...)

It would be more precise to say that they removed the group from their
NNTP server. If your server carries it now, I wouldn't expect them to
drop it in the future.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top