+92 332 4229 857 99ProjectIdeas@Gmail.com

Counting Buttons In Your Form (Vb.net)



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: