VB运行的问题Private Sub command_click()
PrivateSubcommand_click()DimAAsInteger,BAsInteger,CAsSingleDimDAsStringF=InputBox("请输...
Private Sub command_click()
Dim A As Integer, B As Integer, C As Single
Dim D As String
F = InputBox("请输入F的值:")
A = 3B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
问题:
1.这个程序按理来说输出的结果应该是15,为什么运行没有结果?
2.Case 3: C = A * B: D = "×"中D=“x”具体表示什么意思? 展开
Dim A As Integer, B As Integer, C As Single
Dim D As String
F = InputBox("请输入F的值:")
A = 3B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
问题:
1.这个程序按理来说输出的结果应该是15,为什么运行没有结果?
2.Case 3: C = A * B: D = "×"中D=“x”具体表示什么意思? 展开
3个回答
展开全部
首先,你要在窗体内放入一个按钮控件(CommandButton),默认情况下名称为Command1
然后,程序修改为(共有四处修改):
Private Sub Command1_Click() '修改1
Dim A As Integer, B As Integer, C As Single
Dim D As String, F As Integer '修改2
F = Val(InputBox("请输入F的值:")) '修改3
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print A; D; B; "="; C '修改4
End Sub
然后,程序修改为(共有四处修改):
Private Sub Command1_Click() '修改1
Dim A As Integer, B As Integer, C As Single
Dim D As String, F As Integer '修改2
F = Val(InputBox("请输入F的值:")) '修改3
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print A; D; B; "="; C '修改4
End Sub
展开全部
Private Sub command_click()
Dim A As Integer, B As Integer, C As Single
Dim D As String
Me.AutoRedraw = True
F = InputBox("请输入F的值:")
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
相当于D保存的是运算符,方便以后显示使用。(此段代码没有用到D)
Dim A As Integer, B As Integer, C As Single
Dim D As String
Me.AutoRedraw = True
F = InputBox("请输入F的值:")
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
相当于D保存的是运算符,方便以后显示使用。(此段代码没有用到D)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
改成这样
Private Sub command1_click()
Dim A As Integer, B As Integer, C As Single
Dim D As String
F = InputBox("请输入F的值:")
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
Case 3: C = A * B: D = "×"中D=“x”具体表示:
给C赋值,等于A*B
给D赋值,等于“x”,因为定义了D为字符串,赋值D为乘号
Private Sub command1_click()
Dim A As Integer, B As Integer, C As Single
Dim D As String
F = InputBox("请输入F的值:")
A = 3
B = 5
Select Case F
Case 1: C = A + B: D = "+"
Case 2: C = A - B: D = "-"
Case 3: C = A * B: D = "×"
Case 4: C = A / B: D = "÷"
Case Else: End
End Select
Print C
End Sub
Case 3: C = A * B: D = "×"中D=“x”具体表示:
给C赋值,等于A*B
给D赋值,等于“x”,因为定义了D为字符串,赋值D为乘号
追问
懂了
少放了个按钮控件。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询