有一个数组data存放了n个数据,现从中删除了一个元素,其余的元素依次向前递补(假设删除的是第3个元素,则要将第4个元素移到第3个元素处,第5个元素移到第4个元素处,以此类推),然后输出数组内容。程序输入要删除数的位置,点击“删除”按钮后删除指定数,并把剩余的数字依次输出到List2中,程序如图所示。
Dim data(10) As Integer ‘①
Dim n As Integer ‘n表示总元素个数
Private Sub Command1_Click()
Dim t As Integer
t = Val(Text1.Text)
For i = t To n-1
②
Next i
n = n - 1
For i = 1 To n
③
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
n = 10
For i = 1 To n
data(i) = i * 2
List1.AddItem Str(data(i))
Next i
End Sub