编写VB程序,实现上述功能。运行程序,在列表框List1中显示每笔交易流水记录的商品货号与销售金额,单击“分析”按钮Command1,汇总同类商品的销售额并在列表框List2中显示销售额前3名的商品货号与销售金额。程序运行界面如图所示。
(单选,填字母: A .类名/B .属性名/C .方法名/D .事件名)
'n是交易流水的记录总数,ng是商品种类,代码略
Dim goods(1 To n) As String '每笔交易的商品货号
Dim money(1 To n) As Single '每笔交易的销售金额
Dim g(1 To ng) As String
Dim c(1 To ng) As Single
Private Sub Form_ Load ()
'读取每笔交易流水,分别将商品货号存入数组goods、销售金额存入数组money
'g(1)~g (ng)分别存储ng种商品的货号,在List1中显示交易记录信息,代码略
End Sub
Private Sub Command1_Click ()
Dim i As Integer, j As Integer, tc As Single, tg As String
For i=1 To n
For j=1 To ng
If goods(i) = g(j) Then
Next j
Next i
i =1
Do While i <= ng
Fo rj=ng To i+1 Step-1
If c(j)>c(j-1) Then
tc=c(j) : c(j)=c(j-1) : c(j-1)=tc
tg=g(j) : g(j)=g(j-1) : g(j-1)=tg
End If
Next j
If Then Exit Do
i =i+1
Loop
For j=1 To
List2.AddItem g(j) +“”+ Str(c(j))
Next i
End Sub