hi guys.
i want to give a button a text
but i dont want to write
button1.text = 'blabla'
becuase i dont know the button name.
is there anyway to to call the button by a string
for example
"button"&I.text = 'blabla'

Recommended Answers

All 2 Replies

See if this helps.

'// If Button is on Form, use:
        For Each ctl As Control In Me.Controls
            If TypeOf (ctl) Is Button Then
                If ctl.Name = "Button" & l.Text Then
                    ctl.Text = "blabla"
                End If
            End If
        Next

        '// If Button is in a Container, as in a Panel, use:
        For Each ctl As Control In Panel1.Controls
            If TypeOf (ctl) Is Button Then
                If ctl.Name = "Button" & l.Text Then
                    ctl.Text = "blabla"
                End If
            End If
        Next

yes this does
thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.