vb利用二维数组统计员工业绩

问题描述:

vb利用二维数组统计员工业绩
五个员工 六个月
要求统计出每个月的销售冠军和六个月总的销售量冠军.
业绩具体数据自己假设.
1个回答 分类:综合 2014-11-17

问题解答:

我来补答
其实你这个需求用电子表格就可以实现,何必用VB编程呢?
Microsoft Excel 所见即所得,灰常方便!而且数据输入一次就可以了,如果想要更强的功能,它还支持VBscript编程,虽不如VB强悍但是也足够用了.
再问: 作业 没办法。
再答: Dim result(6, 5) As Integer Dim totalr(5) As Integer result(1, 1) = 15: result(1, 2) = 20: result(1, 3) = 30: result(1, 4) = 14: result(1, 5) = 99 result(2, 1) = 25: result(2, 2) = 16: result(2, 3) = 21: result(2, 4) = 39: result(2, 5) = 20 result(3, 1) = 80: result(3, 2) = 11: result(3, 3) = 16: result(3, 4) = 21: result(3, 5) = 39 result(4, 1) = 20: result(4, 2) = 80: result(4, 3) = 13: result(4, 4) = 16: result(4, 5) = 21 result(5, 1) = 13: result(5, 2) = 39: result(5, 3) = 10: result(5, 4) = 80: result(5, 5) = 17 result(6, 1) = 21: result(6, 2) = 21: result(6, 3) = 39: result(6, 4) = 20: result(6, 5) = 80 Dim month, halfyear As Integer Dim i, j As Integer j = 1 i = 1 '求每月最高 For i = 1 To 6 month = CInt(result(i, 1)) curr_1 = 1 For j = 2 To 5 If month < CInt(result(i, j)) Then month = CInt(result(i, j)) curr_1 = j End If Next Print "第" & CStr(i) & "月中五个人,第" & Str(curr_1) & "位月业绩最好,为:" & month Next '求6月中最高 For i = 1 To 6 For j = 1 To 5 totalr(j) = totalr(j) + result(i, j) Next j Next i halfyear = totalr(1) curr_1 = 1 For j = 2 To 5 If halfyear < totalr(j) Then halfyear = totalr(j) curr_1 = j End If Next Debug.Print "总销售业绩五个人中,第" & CStr(curr_1) & "位业绩最好,为:" & halfyear
再问: 能不能改成由button控制然后显示在label上呢? 不想用print 或者窗体
再答: 在Form1上加一个Command1按钮和一个Label1标签 然后输入源代码: Private Sub Command1_Click() Dim result(6, 5) As Integer Dim totalr(5) As Integer result(1, 1) = 15: result(1, 2) = 20: result(1, 3) = 30: result(1, 4) = 14: result(1, 5) = 99 result(2, 1) = 25: result(2, 2) = 16: result(2, 3) = 21: result(2, 4) = 39: result(2, 5) = 20 result(3, 1) = 80: result(3, 2) = 11: result(3, 3) = 16: result(3, 4) = 21: result(3, 5) = 39 result(4, 1) = 20: result(4, 2) = 80: result(4, 3) = 13: result(4, 4) = 16: result(4, 5) = 21 result(5, 1) = 13: result(5, 2) = 39: result(5, 3) = 10: result(5, 4) = 80: result(5, 5) = 17 result(6, 1) = 21: result(6, 2) = 21: result(6, 3) = 39: result(6, 4) = 20: result(6, 5) = 80 Dim month, halfyear As Integer Dim i, j As Integer j = 1 i = 1 Label1.Caption = "" '求每月最高 For i = 1 To 6 month = CInt(result(i, 1)) curr_1 = 1 For j = 2 To 5 If month < CInt(result(i, j)) Then month = CInt(result(i, j)) curr_1 = j End If Next Label1.Caption = Label1.Caption & vbCrLf & "第" & CStr(i) & "月中五个人,第" & Str(curr_1) & "位月业绩最好,为:" & month Next '求6月中最高 For i = 1 To 6 For j = 1 To 5 totalr(j) = totalr(j) + result(i, j) Next j Next i halfyear = totalr(1) curr_1 = 1 For j = 2 To 5 If halfyear < totalr(j) Then halfyear = totalr(j) curr_1 = j End If Next Label1.Caption = Label1.Caption & vbCrLf & "总销售业绩五个人中,第" & CStr(curr_1) & "位业绩最好,为:" & halfyear End Sub
再问: 如果我直接复制的话 就是把这些代码写在button上咯? 但是我们用的是visual web 不是visual basic 没有form啊 而且curr_1也没有定义 系统提示有错
再答: 能不能一次把话说完啊?我之前是在VisualBasic6 上调试的,你现在用什么开发环境啊? 使用VS2005、VS2008、还是VS2010, 是不是VisualStudio的Web开发啊?基本语言是VB.net呗?
再问: 啊 实在是麻烦了 已经解决问题了。灰常感谢啊
 
 
展开全文阅读
剩余:2000
下一页:先解十一题