Vyndrox Posted January 18, 2004 Posted January 18, 2004 Dim txtNew As TextBox = New System.Windows.Forms.TextBox() txtNew.Location = New System.Drawing.Point(25 + f, 248) txtNew.MaxLength = 1 txtNew.Name = "txt" & letter txtNew.ReadOnly = True txtNew.Size = New System.Drawing.Size(16, 20) txtNew.Text = letter txtNew.TextAlign = HorizontalAlignment.Center Controls.Add(txtNew) This is a sample of my code, its from a little game. You have to guess a word, everytime when u input a wrong letter, its dynamicly generates a txtbox with the wrong letter. Now when u guessed the word or it's game over the dynamicly generated textboxes need to be cleared/unloaded. Not just empty but invisible, so you can start another game. Can somebody help me with it. Quote
Moderators Robby Posted January 18, 2004 Moderators Posted January 18, 2004 You can iterate the controls.. Dim c As Control For Each c In Me.Controls If TypeOf c Is TextBox Then c.Dispose() End If Next I suggest placing the textboxes in a Panel so you can simply loop it instead the entire form. For Each c In Panel1.Controls Quote Visit...Bassic Software
Vyndrox Posted January 18, 2004 Author Posted January 18, 2004 tnx, alot for replying. I used this for a solution. Static n Dim s As Integer n = Controls.GetChildIndex(txtNew) For s = 0 To 9 Controls.RemoveAt(n - s) Next s But i need to use you're solution in the future because this time i knew s = 0 to 9, and next time it might be variable. Quote
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.