vb利用二维数组统计员工业绩
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 13:44:06
vb利用二维数组统计员工业绩
五个员工 六个月
要求统计出每个月的销售冠军和六个月总的销售量冠军.
业绩具体数据自己假设.
五个员工 六个月
要求统计出每个月的销售冠军和六个月总的销售量冠军.
业绩具体数据自己假设.
其实你这个需求用电子表格就可以实现,何必用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呗?
再问: 啊 实在是麻烦了 已经解决问题了。灰常感谢啊
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呗?
再问: 啊 实在是麻烦了 已经解决问题了。灰常感谢啊
vb利用二维数组统计员工业绩
VB如何统计二维数组中相同元素的个数?
利用VB,编写一个3*4的二维数组输入任意整数,求所有数组元素和及平均值
【VB】由程序随机产生一个6*6的二维数组,输出数组中的最大元素,统计最大元素所在行的所有元素的乘积.
vb 关于数组的问题1.利用随机函数生成一个4*5的矩阵(二维数组),范围是[1,100]之间的整数,求所有元
利用二维数组实现矩阵的加法运算
求C#高手,统计5*4二维数组中的奇数个数和偶数个数
矩阵,二维数组
VB 输入一个3行4列的二维数组,分别求出每一行、每一列元素之和 要求
VB 二维数组找最大元素位置,要求先设第一行第一列为最大元素,option base 1 求代码
VB随机产生一个M×N二维数组(M,N缺省为4,数组元素为100以内的正整数),计算其
vb程序题:将二维数组A中的100个元素分别赋给一维数组B的每个元素并打印出来