Serious discussion about removing dynamically controls

  • Thread starter Thread starter Cor
  • Start date Start date
Hello:

Really I haven't read a book about programming since I started programming the PC (it was a manual for VB3). I have only read the help provided by Microsoft with posterior releases of VB.

So I'm quite lost (apart from my bad English) when you say things in this context like "screen space is very important" and "Encapsulate it" :'-(

Well, you're really building a great planet of knowledge in this newsgroup and I will take as much advantage of it as I can :-)

Regards.

P.S. Is there any native English-speaking people here? I'm Spanish and I know many of you are not English... ;-)

Regards again.


"Herfried K. Wagner [MVP]" <[email protected]> escribió en el mensaje | Hello,
|
| > But it's a hell of a great planet!!
| >
| > I've seen your method before. It is very unambiguous and there
| > are no worries about whether you are tripping over your own tail.
| > First you collect. Then you remove. Simple.
| >
| > But, as I mentioned in my post above, screen space is very important,
| > so, for me, it is too long.
|
| Encapsulate it...
|
| ;-)))
|
| --
| Herfried K. Wagner
| MVP · VB Classic, VB.NET
| http://www.mvps.org/dotnet
|
|
 
Hi Jose,

I'm a Londoner. You'll get correct English from me and also slang. Naa wot ar mean, like?*

|| "screen space is very important"

By this I mean that I like my code to be as compact as possible so that I can see as much as possible on the screen. That's one
of the reasons that I like C# compared to VB.NET.

C#
public int Foo { get { return m_Foo; } set { m_Foo = (value <= 0) ? 1 : value; }}

vs
Public Property Foo As Integer
Get
Return m_Foo
End Get
Set
m_Foo = IIf (Value <= 0, 1, Value)
End Set
End Property

One line versus 8!!

|| "Encapsulate it"

Herfried is saying. Don't worry about the length - write it as a routine in a a module, eg ControlsLib.RemoveControls
(Collection, Type), and call it. That'll bring it down to a single line it the calling code. And there'll be another useful utility
in the Controls library.

Regards,
Fergus
*
"Naa wot ar mean, like?"
Similar: Get me drift?
Meaning: Does this make sense?
Literally, formally - Do you understand what I mean?

:-)
 
Hi, Fergus:

Thanks for the explanation.

:-)

Regards


"Fergus Cooney" <[email protected]> escribió en el mensaje | Hi Jose,
|
| I'm a Londoner. You'll get correct English from me and also slang. Naa wot ar mean, like?*
|
| || "screen space is very important"
|
| By this I mean that I like my code to be as compact as possible so that I can see as much as possible on the screen. That's one
| of the reasons that I like C# compared to VB.NET.
|
| C#
| public int Foo { get { return m_Foo; } set { m_Foo = (value <= 0) ? 1 : value; }}
|
| vs
| Public Property Foo As Integer
| Get
| Return m_Foo
| End Get
| Set
| m_Foo = IIf (Value <= 0, 1, Value)
| End Set
| End Property
|
| One line versus 8!!
|
| || "Encapsulate it"
|
| Herfried is saying. Don't worry about the length - write it as a routine in a a module, eg ControlsLib.RemoveControls
| (Collection, Type), and call it. That'll bring it down to a single line it the calling code. And there'll be another useful utility
| in the Controls library.
|
| Regards,
| Fergus
| *
| "Naa wot ar mean, like?"
| Similar: Get me drift?
| Meaning: Does this make sense?
| Literally, formally - Do you understand what I mean?
|
| :-)
|
|
 
Hello,

Cor said:
I was thinking about that Yesterday when I did read the message from
Charles, I had always said, in this bussiness it't not important to
know, just to know where it is written.

I fully agree.
And then I thought how would that be with Herfried, but you did send the
answer.

I did make that folder too last week.
A lot of Herfried, Jay B and now Fergus is in it.
The last one was a letter M.
The other things I can remember.

Notice that you can query "all" messages of this ng by using Google Groups
Search.
 
Hello,

Nak said:
Were there computers then? I thought people used the
abacus? ;-)

No, but Commodore or Amiga knowledge doesn't help answering questions in
this ng.

;-)
 
Hello,

José Manuel Agüero said:
So I'm quite lost (apart from my bad English)

Huh. My English is very bad...
when you say things in this context like "screen space is very
important" and "Encapsulate it" :'-(

I wanted to tell you that you write a little procedure that "encapsulates"
the routine and makes it reusable. You don't need to worry about the
implementation every time you use the procedure.
P.S. Is there any native English-speaking people here? I'm Spanish
and I know many of you are not English... ;-)

I live in Austria.

:-)
 
No, but Commodore or Amiga knowledge doesn't help answering questions in

If I were critical, I would say that any computer knowledge helps in any
computer related newsgroup, BTW Amiga's were made by Commodore. :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Nick,
I am quiet sure that Commodore is now owned by Tulip.

I think that when you are talking about the time Amiga was building
Commodore that where the homecomputers then.

Before that time I thought that what was Commodore as a homecomputer in
Germany, was Amiga in England.

(About the last things I am not sure, I never used or had either one of
them)

Cor
 
Hi Cor

The reason that I expressed a preference for the Do While ... Loop method
comes from its simpler form:

<this is not intended to execute ;-)>
Do While Collection.Count > 0
Collection.RemoveAt(0)
Loop
</this is not intended to execute ;-)>

which clearly removes every element from the collection. I like it because
it is short and sweet. Conversely, I have this aversion to using For ...
Next loops where I modify the loop control variable within the loop. It
frightens me.

I realise though, that my example above is in danger of locking if the
RemoveAt(0) fails for any reason, so some form of hat is probably in order.

Regards

Charles
 
Charles,
The do while loop and removing controls(0) goes wrong if some controls have
to stay on the parent control.
The counter comes never to zero and becomes a loop.

That is the nicest thing of the reverse for next

Therefore has the methode from Jack an index and does Jose first collect the
controls that have to be removed.

With both those methodes (I did not evaluate the methode from Nick) is in my
opinion nothing wrong.

The reversal for next which Armin did introduce to me is for me the most
compact to write and most easy to read for others.
When you see it, you understand immidiatly what happens.

When there is not the problem from controls that maybe stay on the parent
control then I choose the code you suggest.

Cor
 
Hello:

Thanks, Cor. I hadn't understood completely the discussion, because of my lack of experience in this groups (apart from the difficulty of speaking in English), I suppose.

I included that code because the first time I used "For Each" loops was with the FileSystemObject to rename files in a folder: the result was that sometimes the files that had changed the name appeared later in the same loop (but not always!), so I started using the method "first collect, then modify".

In respect to the "real" discussion of this thread I prefer explicit code rather than compact: I used compact code when programming my old Amstrad with a Z80, but after some years I prefer clear structures with a declared start and end ("Sub...End Sub" instead of "Proc(){...}"): that's why I don't like C: you end up with a lot of consecutive "}".
There is an example in other thread with one line like this (E is a structure):
E e3=(E) 3
and I prefer:
Dim e3 as E=E.3
I think its much clearer.
I apply the same for different methods of doing the same thing in VB: I always select the clearest one, not the fastest (if speed is not fundamental) nor the "prettiest", nor the most compact.

Well, that's my opinion, after so much posts...

;-) Regards.


"Cor" <[email protected]> escribió en el mensaje | Hi,
| I'll try to "encapsulate" (please don't shoot) the short discussion.
|
| Nick did make a test program and the result was:
| That if you use a "for next loop", or a "do while loop", or with a "crappie
| method" or with a good other method, the process time is almost the same.
|
| Most of the writers are saying after that they had seen the measurement from
| Nick, "Do it your own way?
|
| The ones who prefer the reversal "for next" method do that because of the
| compactness of the code. The ones who prefer the "do while loop" did not
| tell why, maybe it just because they are used to do it that way.
|
| For me it is clear, I will use the "for next" loop in this situation because
| the compactness. And what others say, I gladly follow the words of Jay B.:
| "My concern is there is no 'uniform' answer! As there are multiple ways of
| doing the same thing, equally correct."
|
| Cor
|
|
|
|
|
 
Before that time I thought that what was Commodore as a homecomputer in
Germany, was Amiga in England.

Hi Cor,

Commodore have made many computers, not just Amiga, and we had others
here in England too, Commodore 64 for example. I *thought* that Amiga was a
'subsidiary' (I think I spelt that right) of Commodore, when Amiga went bust
Gateway bought them from Commodore. I *knew* someone who was in development
of a game engine the time that Amiga went bust, tis a shame :-D. You can
still get very good Amiga emulators for PC, http://www.winuae.net/. I hate
Gateway....

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Sorry, British humour :-D

Nout wrong with that! When I were a lad I used to tie two slices of 'ovis
to mah feet, and if it were icy, i'd toast em for t' extra grip!

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Back
Top