VB.net编程初学者出现“索引超出了数组界限”问题,望各位高手解答。
DimnameAsStringDimyuwenAsShortDimshuxueAsShortDimyingyuAsShortDimzongheAsShortDimping...
Dim name As String
Dim yuwen As Short
Dim shuxue As Short
Dim yingyu As Short
Dim zonghe As Short
Dim pingjunfen As Short
xingming = InputBox("输入姓名", "输入名字吧")
yuwen = InputBox("输入语文成绩", vbOKOnly)
shuxue = InputBox("输入数学成绩", vbOKOnly)
yingyu = InputBox("输入英语成绩", vbOKOnly)
zonghe = yuwen + shuxue + yingyu
pingjunfen = zonghe / 3
MsgBox("平均分"(pingjunfen), [vbOKOnly])
错误出现在最后一行,以前我在VB6里也是用这种方法编辑,怎么现在却出错了呢。 展开
Dim yuwen As Short
Dim shuxue As Short
Dim yingyu As Short
Dim zonghe As Short
Dim pingjunfen As Short
xingming = InputBox("输入姓名", "输入名字吧")
yuwen = InputBox("输入语文成绩", vbOKOnly)
shuxue = InputBox("输入数学成绩", vbOKOnly)
yingyu = InputBox("输入英语成绩", vbOKOnly)
zonghe = yuwen + shuxue + yingyu
pingjunfen = zonghe / 3
MsgBox("平均分"(pingjunfen), [vbOKOnly])
错误出现在最后一行,以前我在VB6里也是用这种方法编辑,怎么现在却出错了呢。 展开
2个回答
展开全部
在VB里,"平均分"(pingjunfen), 这是数组的调用方法,当然会报错了
这样改吧:
Dim xingming As String
Dim yuwen As Short
Dim shuxue As Short
Dim yingyu As Short
Dim zonghe As Short
Dim pingjunfen As Short
xingming = InputBox("输入姓名", "输入名字吧")
yuwen = InputBox("输入语文成绩", vbOKOnly)
shuxue = InputBox("输入数学成绩", vbOKOnly)
yingyu = InputBox("输入英语成绩", vbOKOnly)
zonghe = yuwen + shuxue + yingyu
pingjunfen = zonghe / 3
MsgBox("平均分:" & pingjunfen, [vbOKOnly])
这样改吧:
Dim xingming As String
Dim yuwen As Short
Dim shuxue As Short
Dim yingyu As Short
Dim zonghe As Short
Dim pingjunfen As Short
xingming = InputBox("输入姓名", "输入名字吧")
yuwen = InputBox("输入语文成绩", vbOKOnly)
shuxue = InputBox("输入数学成绩", vbOKOnly)
yingyu = InputBox("输入英语成绩", vbOKOnly)
zonghe = yuwen + shuxue + yingyu
pingjunfen = zonghe / 3
MsgBox("平均分:" & pingjunfen, [vbOKOnly])
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询