Below is code that will place 2 controls on the form. And Build a class.
When the button is clicked it will fill the listbox with the contents of the class, and count the number of entries... I need to know how to sum the amounts.
Code:
Public Class Form1
Dim btn As New Button
Dim l1 As New ListBox
Dim b As New Bill
Dim lB As New List(Of Bill)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btn = New Button
btn.Text = "Click To Aggregate"
btn.Size = New Size(160, 140)
Me.Controls.Add(btn)
AddHandler btn.Click, New System.EventHandler(AddressOf BTN_Click)
l1 = New ListBox
l1.Size = New Size(200, 200)
l1.Location = New Point(140, 140)
Me.Controls.Add(l1)
BuildBill()
End Sub
Public Sub BuildBill()
b = New Bill
b.Name = "ME "
b.Amount = "2"
lB.Add(b)
b = New Bill
b.Name = "You "
b.Amount = "4"
lB.Add(b)
b = New Bill
b.Name = "Them "
b.Amount = "5"
lB.Add(b)
b = New Bill
b.Name = "Us "
b.Amount = "3"
lB.Add(b)
End Sub
Public Sub BTN_Click()
Dim query = From gg In lB
For Each gg In query
l1.Items.Add(gg.Name & gg.Amount)
Next
l1.Items.Add("There Are " & query.Count & " Entries")
MsgBox("How Would I Aggregate This Class to give me the sum of the Amounts?")
End Sub
<Serializable()> Public Class Bill
Private _Name As String
Private _Amount As String
Property Name As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Property Amount As String
Get
Return _Amount
End Get
Set(ByVal value As String)
_Amount = value
End Set
End Property
End Class
End Class
nothing I've looked at in helps will compile...