473,463 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Wierd For...Each behavior

Tom
This is very strange: I have a Windows Form with a Panel on it. In that
panel I dynamically (at run time) create some labels, as so:

for i=1 to x
dim ctlNew as New Label()
with ctlNew
.Name="Whatever" & trim(cstr(i))
.Text=.Name
.Visible=True
... etc etc etc ...
end with
MyPanel.Controls.Add(ctlNew)

This shows up fine when the form is displayed. However, I also have a reset
button on the form, which goes thru and destroys the labels, as such:

dim ctl as Control
for each ctl in MyPanel.Controls
if typeof ctl is Label then
ctl.text=""
ctl.visible=False
ctl.Dispose()
end if
next

OK, here is the WIERD thing: The For...Each loop only seems to pick up the
EVEN or ODD numbered controls! It skips some of the controls (i.e. the odd
ones).... if I rerun the loop about three times, one right after the other,
it will finally pick up all the controls and get rid of them.

I -think- the code is correct - I even added a ctl=Nothing before and/or
after the ctl.Dispose(), but it didn't help. The For...Each loop just seems
the skip some of the label controls during its run. I am baffled ... even
though it is probably something dumb that I am doing.

Anyone got any ideas on this?

Tom

Nov 20 '05
112 3910
Nak
> ;-)

Oh I see, keeping it a secret huh? :-)

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #101
Hi Nick,

Lol. Sounds like Monty to me. :-)

Regards,
Fergus
Nov 20 '05 #102
Hi Cor,

|| The code Tom used, showed for me that he was not a beginner

Absolutely. Your code gave the how. It's quite within Tom's capabilities to turn that into an "exactly how".

|| .. did gave me a good feeling
|| Thanks all

You're welcome. [And a good fight, er, I mean discussion, is nice from time to time.]

Cheers, :-)
Fergus
Nov 20 '05 #103
Cor
Fergus
You said that I thought, lets take one yes.
Proost
Cor
Nov 20 '05 #104
Hi Nick,

|| That was very powerful, ...

Thank you :-)

|| ... ever thought of getting into politics?

Ah! For a minute there I thought it was a compliment. No. I <will> take it as a compliment, lol.

I think you acquitted yourself pretty well too, I might add. I did enjoy your Busta Bludvessel, and you made several good
serious points, too.

|| I believe there is actually a thread of community
|| in this newsgroup

So do I. I have an image of us as buddies walking down the High Street doing good deeds - guiding old ladies unsure of the
traffic, helping people push their out-of-petrol car to the side of the road or even to the garage, picking up dummies dropped by
little girls in lilac, that sort of thing. And 'educating' punks who discard litter on the street with no consciousness of how
community works. :-D

Cheers, buddy,
Fergus
Nov 20 '05 #105
Proost!
Nov 20 '05 #106
Hello,

"Cor" <no*@non.com> schrieb:
You said that I thought, lets take one yes.
Proost


What does "Proost" mean?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #107
Hello,

"Cor" <no*@non.com> schrieb:
Fergus and of course all others,
:-)
That is early this morning, I am suprissed.
Even Nick did support me and after a while even Herfried showed
he became angry, did gave me a good feeling.
The errors where so little and bassicly I was expecting from the supplied
code from Tom that only some hints where necassery.
The code Tom used, showed for me that he was not a beginner but just was
searching for some things he could not find.


Jack's criticism was basically correct and your code was not
"best-practice", nevertheless, I liked the discussion caused by your
posting. I saw some really interesting code snippets.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #108
Cor
Proost


Salute
Cheers
Prosit
Na zdrowie
Chin Chin
Nazadarowie
Nov 20 '05 #109
Bottoms up
Cheerio
Don't tell the missus
....
"Cor" <no*@non.com> wrote in message
news:3f***********************@reader21.wxs.nl...
Proost


Salute
Cheers
Prosit
Na zdrowie
Chin Chin
Nazadarowie

Nov 20 '05 #110
Nak
> Lol. Sounds like Monty to me. :-)

LOL, BTW have you seen my program...

http://members.lycos.co.uk/nickpatemanpwp/soft-ffc.htm

The idea was taken from "Monty Python's Flying Circus", I know the
animations look crappy but they can be very funny too. It was an excellent
way to learn XML doing something like that.

I *did* have animations of past work "acquaintances" but unfortunately had
to remove them recently, they will be back though, in the form of a parody,
there is no better way to pi55 someone off! ;-)

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #111
Proost


Bottoms up,
Down the hatch.
Nov 20 '05 #112
Hello,

"Cor" <no*@non.com> schrieb:
Proost


Salute
Cheers
Prosit
Na zdrowie
Chin Chin
Nazadarowie


Thanks. In German, people say "Prost" to each other when drinking beer.
"Prosit Neujahr!" is used to wish someone the best for the new year.

;-)))

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #113

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Qun Cao | last post by:
Hello, I am just starting to play threading in python, here is a really interesting problem I am very curious about: " import thread def main(): thread.start_new(test.()) def test():
0
by: Niranjan | last post by:
Access XP Windows XP This code has been working for over 5 years with no problems and all of a sudden I am running into these wierd problems. I have this code to delete a record....
1
by: paul reed | last post by:
Hello, I am having some weird behavior between two machines...one which is running the 1.1 framework and one which is running 1.0. After opening a child form from a parent...I update the...
3
by: Michael Loughry | last post by:
I'm working for a company in Houston developing a web application. At one point in the code, we have to refresh the page, but save what checkboxes have been selected. Since these checkboxes are...
14
by: SStory | last post by:
I am trying to make a splash screen for my vb.net app. It is an mdi app. including the splash code produces wierd results. not inluding makes things fine. Also have tried loading the splash...
0
by: Tom | last post by:
OK, here's a wierd one... I have a listbox, which I fill with strings (in my case, file names). I normally load this via a loop, adding each item to the list box in the loop. I put lb.BeginUpdate...
3
by: Tom | last post by:
We are experiencing some wierd debugging behavior. What happens is that, during debugging with VS 2003, the debugger seems to 'skip' statements that are associated with database operations. For...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
4
by: Muthu Arumugam | last post by:
Tried the following c# code static void Main(string args) { ArrayList list = new ArrayList(); int i = 10;
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.