VB编写程序,用InputBox输入3个数字。如果用这3个数作为边长,判断它们能否构成三
答案:4 悬赏:0
解决时间 2021-12-13 05:32
- 提问者网友:朱砂泪
- 2021-12-12 17:22
把编程发给我 求求各位大仙们了 通过了我把所有的金币都给你 急
最佳答案
- 二级知识专家网友:摧毁过往
- 2021-12-12 18:49
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
全部回答
- 1楼网友:努力只為明天
- 2021-12-12 22:18
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
- 2楼网友:许你一世温柔
- 2021-12-12 21:49
按照你的要求,在窗体上创建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
- 3楼网友:青春如此荒謬
- 2021-12-12 20:26
dim num as integer, i as integer num = val(inputbox("请输入待判定的值")) if num > 2 then for i = 2 to sqr(num) if num mod i = 0 then exit for next i if i <= sqr(num) then msgbox (str(num) + "不是素数") else msgbox (str(num) + "是素数") end if else if num = 2 then msgbox (str(num) + "是素数") else msgbox (str(num) + "不是素数") end if end if end sub
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯