把这张流程图写成VB代码
4个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer,k as Integer
Dim x As Single, s1 As Single
Dim tmp(0 To 2) As Single
s = 0
For i = 0 To 2
x = Val(InputBox("请输入第 " & i + 1 & " 个数:"))
tmp(i) = x
Next
For i = 0 To 2
For k = i + 1 To 2
If tmp(k) > tmp(i) Then
s1 = tmp(i)
tmp(i) = tmp(k)
tmp(k) = s1
End If
Next
Next
MsgBox " 最小" & tmp(2)
End Sub
Dim i As Integer,k as Integer
Dim x As Single, s1 As Single
Dim tmp(0 To 2) As Single
s = 0
For i = 0 To 2
x = Val(InputBox("请输入第 " & i + 1 & " 个数:"))
tmp(i) = x
Next
For i = 0 To 2
For k = i + 1 To 2
If tmp(k) > tmp(i) Then
s1 = tmp(i)
tmp(i) = tmp(k)
tmp(k) = s1
End If
Next
Next
MsgBox " 最小" & tmp(2)
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'在窗体上添加一个commandbutton,三个textbox:
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, tmp As Single
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
If a > b Then
If b > c Then
tmp = c
Else
tmp = b
End If
Else
If a > c Then
tmp = c
Else
tmp = a
End If
End If
MsgBox "最小的数为 " & tmp
End Sub
Private Sub Form_Load()
Me.Caption = "输入三个数,求出最小的数。"
Command1.Caption = "开始"
Text1 = ""
Text2 = ""
Text3 = ""
End Sub
或者:
Private Sub Command1_Click()
Dim aTemp(2), tmp As Single
aTemp(0) = Val(Text1(0))
aTemp(1) = Val(Text1(1))
aTemp(2) = Val(Text1(2))
If aTemp(0) > aTemp(1) Then
If aTemp(1) > aTemp(2) Then
tmp = aTemp(2)
Else
tmp = aTemp(1)
End If
Else
If aTemp(0) > aTemp(2) Then
tmp = aTemp(2)
Else
tmp = aTemp(0)
End If
End If
MsgBox "最小的数为 " & tmp
End Sub
Private Sub Form_Load()
Me.Caption = "输入三个数,求出最小的数。"
Command1.Caption = "开始"
Text1(0) = ""
Text1(1) = ""
Text1(2) = ""
End Sub
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, tmp As Single
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
If a > b Then
If b > c Then
tmp = c
Else
tmp = b
End If
Else
If a > c Then
tmp = c
Else
tmp = a
End If
End If
MsgBox "最小的数为 " & tmp
End Sub
Private Sub Form_Load()
Me.Caption = "输入三个数,求出最小的数。"
Command1.Caption = "开始"
Text1 = ""
Text2 = ""
Text3 = ""
End Sub
或者:
Private Sub Command1_Click()
Dim aTemp(2), tmp As Single
aTemp(0) = Val(Text1(0))
aTemp(1) = Val(Text1(1))
aTemp(2) = Val(Text1(2))
If aTemp(0) > aTemp(1) Then
If aTemp(1) > aTemp(2) Then
tmp = aTemp(2)
Else
tmp = aTemp(1)
End If
Else
If aTemp(0) > aTemp(2) Then
tmp = aTemp(2)
Else
tmp = aTemp(0)
End If
End If
MsgBox "最小的数为 " & tmp
End Sub
Private Sub Form_Load()
Me.Caption = "输入三个数,求出最小的数。"
Command1.Caption = "开始"
Text1(0) = ""
Text1(1) = ""
Text1(2) = ""
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
流程图都出来了,用IF就OUT了的
追问
具体的不会写啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询