销售数据未以表格形式显示

时间:2013-10-22 18:38:56

标签: vb.net

尝试计算5个商品,3个商店的总销售额。 这是我得到的s / s以及我的代码。 我错过了什么/做错了什么? (p.s.它没有在'debug'中返回错误代码) enter image description here

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

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:1)

看起来你忘了在这里贴东西了。它什么都不做

 For store As Integer = 0 To 2
      For item As Integer = 0 To 4
      Next
 Next