|
-
Jul 26th, 2004, 09:42 AM
#1
Thread Starter
Fanatic Member
For Each....?
How would I use the "For Each" to do the following....
Dim counter as Integer
For counter = 0 to myWidgetCollection.Count - 1
MessageBox.Show(myWidgetCollection.Item(counter).Name)
Next
***** I AM TRYING TO DO THIS EXAMPLE ...........
http://msdn.microsoft.com/library/de...ctionClass.asp
Last edited by birthjay; Jul 26th, 2004 at 10:02 AM.
-
Jul 26th, 2004, 09:45 AM
#2
Assuming that myWidgetCollection holds a myWidgetClass.
I think you have to implement an IEnumerable Interface in myWidgetClass.
this might help it's in C# but it should be easy enough to port
Last edited by DeadEyes; Jul 26th, 2004 at 09:51 AM.
-
Jul 26th, 2004, 12:02 PM
#3
Hyperactive Member
VB Code:
Dim widget as myWidgetClass
For each widget in myWidgetCollection.Items
MessageBox.Show(widget.Name)
Next
-
Jul 26th, 2004, 12:36 PM
#4
Thread Starter
Fanatic Member
Thanks folks.....
I am trying to create a forms collection in VB.NET because I am converting a VB6 project to VB.NET.
I found this article:
http://support.microsoft.com/default...b;EN-US;308537
at Microsoft that supposedly tells you how to do it. I have a question about it.....
On the part where it says..."Add and Remove Forms from the Collection".....where exactly is that code put? Is it in the module they are talking about etc....etc..
Thanks!
-
Jul 26th, 2004, 01:08 PM
#5
Hi.
Declare your collection at module level as public.
Then in form_load of each form add the form to the collection.
In form_closing, remove the form from the collection.
VB Code:
Private Sub Form_Load(ByVal sender As Object,ByVal e As EventArgs) Handles MyBase.Load
MyForms.Add(Me)
End Sub
Private Sub Form_Closing(ByVal sender As Object,ByVal e As EventArgs) Handles MyBase.Closing
MyForms.Remove(Me)
End Sub
I haven't tested this, but I'm pretty sure it could work.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|