VB编程,求教选择结构
来源:百度知道 编辑:UC知道 时间:2024/04/28 15:28:58
由键盘输入3个数,编程将它们按照从小到大的顺序打印出来
窗体上放2个文本筐用于显示输入的数据和进行排序后的数据,1个标签,2个命令按纽
代码如下(直接拷贝),如下图所示
Option Explicit: Dim max As Double, max1 As Double, min As Double, a(2) As Double, i As Integer, str As String, t As Double
Private Sub Command1_Click()
For i = 0 To 2
a(i) = InputBox("请输入一个数")
str = str & a(i) & " "
Text1.Text = str
Next i
End Sub
Private Sub Command2_Click()
If a(0) < a(1) Then min = a(0): max = a(1) Else min = a(1): max = a(0)
If max < a(2) Then t = max: max = a(2): max1 = t
If max > a(2) And