How could I add array values and populate the results in a specified text box?Then repeat for each line after. Then get a final total. Any help would be very appreciated.
For example:
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

7 Years
Discussion Span
Last Post by ITGuy2010

The following code is for adding values to an array:

test.add(<The number you want>)

Then to get the sum of the values given:

for each( i As integer in test)
..(code to add the Integer i into another var called sum)

And finally, to show the sum variable into a textbox:

<textboxname>.text = sum

Hope i answered your question! :D

Votes + Comments
Very Helpful

Please show your code work.

I apologize, Here is the code I have thus far...Now I would like to add the Sales Revenue for each of the three rows and populate them in their own text box and then get a sum of the three text boxes. Any help would be very much appreciated!

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
            strItemsSold &= vbCrLf & vbCrLf

        MessageBox.Show(strItemsSold, "Daily Sales Revenue")

        Return SalesRevenue
    End Function
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.