The following code shows you counting all the buttons in you form and write their names in listbox.
Imports System.Linq
Dim query As IEnumerable(Of Control) = _
From control As Control In Me.Controls _
Where TypeOf (control) Is Button _
Select control
Dim countButton As Integer = query.Count() ' counting a button
Label1.Text = "The following" & countButton & "are on this form and text written on them is: "
For Each con As Control In query
ListBox1.Items.Add(con.Name)
Next
0 comments:
Post a Comment