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”具体表示什么意思?
展开
 我来答
网海1书生
科技发烧友

2015-03-11 · 擅长软件设计、WEB应用开发、小程序
网海1书生
采纳数:12311 获赞数:26228

向TA提问 私信TA
展开全部
首先,你要在窗体内放入一个按钮控件(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
mying_2002
推荐于2016-09-08 · TA获得超过1035个赞
知道小有建树答主
回答量:295
采纳率:0%
帮助的人:301万
展开全部
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)
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
Funcat
2015-03-11 · TA获得超过590个赞
知道小有建树答主
回答量:760
采纳率:86%
帮助的人:355万
展开全部
改成这样

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为乘号
追问
懂了
少放了个按钮控件。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式