V
V
vova_king2015-06-22 21:57:58
Windows Forms
vova_king, 2015-06-22 21:57:58

How to clear all TextBoxes on a form in visual basic 2013?

Good time of the day everyone!
I took the code to clear all TextBoxes on the form

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        For I As Integer = 1 To 13
            Me.Controls("TextBox" & I).Text = ""
        Next
    End Sub

Specified to clear the form when loading 13 textbox
The textbox data is in Groupbox
When reloading the form, an error appears.
There is a suspicion that this is due to Groupbox, How to clear all textboxes located in Groupbox?
eb928e1a42d7470a9772aba6c9b5d72a.png
Indicated even in the menu when loading the form to clear everything, still an error!
d0649be57313475db23ab43ca6f21ad2.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vova_king, 2015-06-22
@vova_king

Maybe someone will come in handy

Dim ss = GroupBox1.Controls ' массив со всеми компонентами гроупбокса
        For i = 0 To ss.Count - 1 ' прокручиваем все компоненты по одному
            If ss.Item(i).Name.ToString.Substring(0, 4) = "Text" Then ss.Item(i).Text = "" ' свойство компонента text = ""
        Next

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question