1 2 3 4 5 (15)-text box
1 2 3 4 5 (15)-text box
2 4 4 3 5 (18)-text box
-----------------------
(48)-text box
Code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim ItemCost() As Decimal = {12D, 17.95D, 95D, 86.5D, 78D}
Dim SoldItems(,) As Integer = New Integer(,) {{txtS1I1.Text, txtS1I2.Text, txtS1I3.Text, txtS1I4.Text, txtS1I5.Text}, _
{txtS2I1.Text, txtS2I2.Text, txtS2I3.Text, txtS2I4.Text, txtS2I5.Text}, _
{txtS3I1.Text, txtS3I2.Text, txtS3I3.Text, txtS3I4.Text, txtS3I5.Text}}
Dim totals(,) As Decimal = Calculate(SoldItems, ItemCost)
End Sub
Private Function Calculate(ByVal SoldItems(,) As Integer, ByVal itemCost() As Decimal) As Decimal(,)
Dim SalesRevenue(SoldItems.GetUpperBound(0), SoldItems.GetUpperBound(1)) As Decimal
Dim strItemsSold As String = ""
Dim sum As String = ""
For r As Integer = 0 To SoldItems.GetUpperBound(0)
For c As Integer = 0 To SoldItems.GetUpperBound(1)
SalesRevenue(r, c) = CDec(SoldItems(r, c) * itemCost(c))
strItemsSold &= FormatCurrency(SalesRevenue(r, c), 2) & vbTab
Next
strItemsSold &= vbCrLf & vbCrLf
Next
MessageBox.Show(strItemsSold, "Daily Sales Revenue")
Return SalesRevenue
End Function
