0

试图计算 5 件商品、3 家商店的总销售额。这是我得到的内容以及我的代码。我错过了什么/做错了什么?(ps它没有在“调试”中返回错误代码) 在此处输入图像描述

Public Class Form1

    Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
        Dim ttlsales As Double
        'set up array data

        Dim sales(,) As Integer = {{25, 64, 23, 45, 14},
                                  {12, 82, 19, 34, 63},
                                   {54, 22, 17, 43, 35}}
        Dim price() As Double = {12.0, 17.95, 95.0, 86.5, 78.0}

        'mark totals
        Dim totals(2) As Double
        For store As Integer = 0 To 2
            For item As Integer = 0 To 4
            Next
        Next

        'display output
        lstOut.Items.Add("Sales Per Store")
        For store As Integer = 0 To 2
            lstOut.Items.Add(store + 1 & ":" &
                             FormatCurrency(totals(store)))
            ttlsales += totals(store)
        Next

        lstOut.Items.Add("Total Sales: " &
                         FormatCurrency(ttlsales))


    End Sub
End Class
4

2 回答 2

2

乍一看,你没有在你的双 for 循环中做任何事情

Dim totals(2) As Double
For store As Integer = 0 To 2
            For item As Integer = 0 To 4
            Next
        Next
于 2013-10-22T18:42:10.017 回答
1

看起来你忘了把东西放在这里。它什么也不做

 For store As Integer = 0 To 2
      For item As Integer = 0 To 4
      Next
 Next
于 2013-10-22T18:41:54.110 回答