VB编写程序,用InputBox输入3个数字。如果用这3个数作为边长,判断它们能否构成三
3个回答
展开全部
按照你的要求,在窗体上创建3个按钮,分别代表3个题目,创建一个label用于第一个题目显示数据:
复制以下代码,运行即可:
Private Sub Command1_Click()
Label1.Caption = Val(InputBox("请输入商品的单价:", "输入", 50)) * Val(InputBox("请输入商品的数量:", "数量", 10)) & "元!"
End Sub
Private Sub Command2_Click()
Dim n As Single
n = Val(InputBox("请输入一个数:"))
Print n; "的平方是:" & Format(n ^ 2, "0.000"); "平方根是:" & Format(Sqr(n), "0.000"); "立方是:" & Format(n ^ 3, "0.000"); "立方根是:" & Format(n ^ (1 / 3), "0.000")
End Sub
Private Sub Command3_Click()
Dim i As Integer, n As Single
Dim max, min
For i = 1 To 3
n = InputBox("请输入第" & i & "个数字")
If max = "" Then max = n Else If max < n Then max = n
If min = "" Then min = n Else If min > n Then min = n
Next
Print "最大数是:" & max
Print "最小数是:" & min
End Sub
复制以下代码,运行即可:
Private Sub Command1_Click()
Label1.Caption = Val(InputBox("请输入商品的单价:", "输入", 50)) * Val(InputBox("请输入商品的数量:", "数量", 10)) & "元!"
End Sub
Private Sub Command2_Click()
Dim n As Single
n = Val(InputBox("请输入一个数:"))
Print n; "的平方是:" & Format(n ^ 2, "0.000"); "平方根是:" & Format(Sqr(n), "0.000"); "立方是:" & Format(n ^ 3, "0.000"); "立方根是:" & Format(n ^ (1 / 3), "0.000")
End Sub
Private Sub Command3_Click()
Dim i As Integer, n As Single
Dim max, min
For i = 1 To 3
n = InputBox("请输入第" & i & "个数字")
If max = "" Then max = n Else If max < n Then max = n
If min = "" Then min = n Else If min > n Then min = n
Next
Print "最大数是:" & max
Print "最小数是:" & min
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim e As Single
a = InputBox("a=")
b = InputBox("b=")
c = InputBox("c=")
d = WorksheetFunction.max(a, b, c)
e = WorksheetFunction.min(a, b, c)
If d < a + b + c - d And e > d - (a + b + c - d - e) Then
MsgBox "行"
Else
MsgBox "不行"
End If
End Sub
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim e As Single
a = InputBox("a=")
b = InputBox("b=")
c = InputBox("c=")
d = WorksheetFunction.max(a, b, c)
e = WorksheetFunction.min(a, b, c)
If d < a + b + c - d And e > d - (a + b + c - d - e) Then
MsgBox "行"
Else
MsgBox "不行"
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
a = InputBox("a=")
b = InputBox("b=")
c = InputBox("c=")
If (a + b) > c And Abs(a - b) < c And (a + c) > b And Abs(a - c) < b And (b + c) > a And Abs(b - c) < a Then
MsgBox "行"
Else
MsgBox "不行"
End If
End Sub
Dim a As Single
Dim b As Single
Dim c As Single
a = InputBox("a=")
b = InputBox("b=")
c = InputBox("c=")
If (a + b) > c And Abs(a - b) < c And (a + c) > b And Abs(a - c) < b And (b + c) > a And Abs(b - c) < a Then
MsgBox "行"
Else
MsgBox "不行"
End If
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询