VB程序编写:使用inputbox()函数输入学生三科成绩然后用msgbox函数输出平均成绩
我平时先建立一个Button然后双击它写代码我的代码如下但是结果不对哪位大侠帮帮忙啊DimaAsStringDimbAsStringDimcAsStringDimdAsS...
我平时先建立一个Button 然后双击它写代码 我的代码如下 但是结果不对 哪位大侠帮帮忙啊
Dim a As String Dim b As String
Dim c As String
Dim d As String
a = Val(InputBox("请输入计算机成绩", "成绩输入", ""))
b = Val(InputBox("请输入英语成绩", "成绩输入", ""))
c = Val(InputBox("请输入语文成绩", "成绩输入", ""))
d = Val((a + b + c) / 3)
MsgBox(d, , "平均分") 展开
Dim a As String Dim b As String
Dim c As String
Dim d As String
a = Val(InputBox("请输入计算机成绩", "成绩输入", ""))
b = Val(InputBox("请输入英语成绩", "成绩输入", ""))
c = Val(InputBox("请输入语文成绩", "成绩输入", ""))
d = Val((a + b + c) / 3)
MsgBox(d, , "平均分") 展开
3个回答
展开全部
Private Sub Command1_Click()
Dim a, b, c, d As Single
a = Val(InputBox("请输入计算机成绩", "成绩输入", ""))
b = Val(InputBox("请输入英语成绩", "成绩输入", ""))
c = Val(InputBox("请输入语文成绩", "成绩输入", ""))
d = Val((a + b + c) / 3)
MsgBox "平均分" & d, 64
End Sub
Dim a, b, c, d As Single
a = Val(InputBox("请输入计算机成绩", "成绩输入", ""))
b = Val(InputBox("请输入英语成绩", "成绩输入", ""))
c = Val(InputBox("请输入语文成绩", "成绩输入", ""))
d = Val((a + b + c) / 3)
MsgBox "平均分" & d, 64
End Sub
展开全部
4个变量的数据类型不对,最好用实型数,不要用String
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a As String
Dim b As String
Dim c As String
Dim d As String
改成:
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim b As String
Dim c As String
Dim d As String
改成:
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询