【正确答案】 Option Explicit
Option Base 1
Private Sub CmdRun_Click()
Dim a() As Integer,n As Integer,i As Integer
Dim sum As Integer,av As Integer,k As Integer
n=InputBox("输入数据个数:", ,12)
ReDim a(n)
For i=1 To n
a(i)=Int(Rnd*41)+10
Text1=Text1 & Str(a(i))
Next i
Call sort(a)
For i=1 To UBound(a) Step 3
sum=0
For k=i To i+2
sum=sum+a(k)
Next k
av=sum/3
For k=1 To 3
Text3=Text3 & Str(av)
Next k
Next i
End Sub
Private Sub sort(a()As Integer)
Dim i As Integer,j As Integer,t As Integer
For i=1 To UBound(a)-1
Forj=1 To UBound(a)-i
If a(j)>a(j+1)Then
t=a(j)
a(j)=a(j+1)
a(j+1)=t
End If
Next j
Next i
For i=1 To UBound(a)
Text2=Text2 & Str(a(i))
Next i
End SUb
Private Sub CmdClear_click()
Text1=""
Text2=""
Text3=""
CmdRun.SetFocus
End Sub
Private Sub CmdExit_click()
End
End Sub