执行下面程序,在文本框Text1中输入"21 23 2 3 5 17 54#"后,单击命令按钮Cmdl,数组元素A(1)的值是(),A(3)的值是(),A(5)的值是().
Option Explicit
Private Sub Cmd1_Click()
Dim A() As Integer,K As Integer
Dim L As Integer,S As String
S=Text1
Do
K=K+1
ReDim Preserve A(K)
L=InStr(S," ")
If L<>0 Then
A(K)=Val(Left(S,L-1))
S=Right(S,Len(S)-L)
Else
A(K)=Val(S)
End If
Loop Until L=0
Call Exchang(A)
For K=1 To 7
Text2=Text2 &A(K) & " "
Next K
End Sub
Private Sub Exchang(A() As Integer)
Dim i As Integer,Tem As Integer
Dim Point1 As Integer
Point1=1
For i=1 To UBound(A)
If A(i) Mod 3 =0Then
Tem=A(i)
A(i)=A(Point1)
A(Point1)=Tem
Point1=Point1+1
End If
Next i
End Sub