在vb中,如何把数组的一部分赋值给另一个数组
Dim intArray(1 To 100) As Integer
Private Sub Command1_Click()
Label1.Caption = ""
Randomize (Timer)
For i = LBound(intArray) To UBound(intArray)
10 intArray(i) = Int(Rnd(i) * 9000 + 1000)
For j = LBound(intArray) To i - 1
If intArray(i) = intArray(j) Then GoTo 10
Next j
Next i
For i = LBound(intArray) To UBound(intArray)
Label1.Caption = Label1.Caption + CStr(intArray(i)) + Space(1)
If i Mod 10 = 0 Then Label1.Caption = Label1.Caption + vbCrLf
Next i
End Sub
Private Sub Command2_Click()
Label2.Caption = ""
Dim Flag As Boolean, intPrimeArray(1 To 100) As Integer
For i = LBound(intArray) To UBound(intArray)
Flag = True
For j = 2 To Sqr(intArray(i))
If intArray(i) Mod j = 0 Then
Flag = False
Exit For
End If
Next j
If Flag Then
k = k + 1
intPrimeArray(k) = intArray(i)
End If
Next i
For i = LBound(intArray) To k
Label2.Caption = Label2.Caption + CStr(intPrimeArray(i)) + Space(1)
If i Mod 10 = 0 Then Label2.Caption = Label2.Caption + vbCrLf
Next i
End Sub