编程,VB题
在三个文本框上输入不等整数x,y,z,排列一下使得结果为x>y>z,并将结果依次显示在窗体的左上角。要求定义一个交换两个数的子过程,通过调用子过程的方式来求解。...
在三个文本框上输入不等整数x,y,z,排列一下使得结果为x>y>z,并将结果依次显示在窗体的左上角。要求定义一个交换两个数的子过程,通过调用子过程的方式来求解。
展开
1个回答
展开全部
Option Explicit
Private Sub Command1_Click()
Dim a%(3)
a(1) = Text1.Text
a(2) = Text2.Text
a(3) = Text3.Text
Call Turn(a)
For a(0) = 1 To UBound(a)
Print a(a(0))
Next
End Sub
Private Sub Turn(a%())
Dim i%, j%
For i = 1 To UBound(a)
For j = i + 1 To UBound(a)
If a(i) < a(j) Then
a(0) = a(i)
a(i) = a(j)
a(j) = a(0)
End If
Next
Next
End Sub
Private Sub Command1_Click()
Dim a%(3)
a(1) = Text1.Text
a(2) = Text2.Text
a(3) = Text3.Text
Call Turn(a)
For a(0) = 1 To UBound(a)
Print a(a(0))
Next
End Sub
Private Sub Turn(a%())
Dim i%, j%
For i = 1 To UBound(a)
For j = i + 1 To UBound(a)
If a(i) < a(j) Then
a(0) = a(i)
a(i) = a(j)
a(j) = a(0)
End If
Next
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询