andrew104 Posted December 3, 2002 Posted December 3, 2002 How do you clear a collection consisting of labels and text boxes? me.collection1.clear or Clear(collection1) do not work. Thanks. Quote
*Gurus* divil Posted December 3, 2002 *Gurus* Posted December 3, 2002 I assume you're using the VB.NET Collection class. You should really try and use one of the .NET collection classes under System.Collections. Anyway, since the VB.NET Collection class has no clear method it looks like you'll have to loop through it to clear it: Do While myCollection.Count <> 0 myCollection.Remove(0) Loop Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
wyrd Posted December 3, 2002 Posted December 3, 2002 You could just; myCollection = New Collection() Quote Gamer extraordinaire. Programmer wannabe.
andrew104 Posted December 5, 2002 Author Posted December 5, 2002 Ok, I STILL cannot get the stupid clear collection thing. Here is exactly what I need to do. When the user clicks the ClearButton, The InputTextBox should clear along with all of the display labels The focus should return to the InputTextBox and The ClearLabel should be disabled. The Clear Routine must be written using collections and a For/Each loop. To do this, create a collection of all display labels and use the loop to clear them. None of the suggestions below (although appreciated) worked. Quote
wyrd Posted December 5, 2002 Posted December 5, 2002 Sounds like someone has a homework assignment. ;) Assuming I read your post right... Dim l as Label For Each l In YourLabelCollection l.Text = "" Next InputTextBox.Text = "" InputTextBox.Focus() ClearLabel.Enabled = False Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.