如何在VB中删除数组中指定位置的元素?各位好心人进来看看吧!

这是我的一道VB复习题,填空的,谢谢各位大哥大姐帮忙,顺便说下简单的道理,再次感谢!!!
Option Explicit
Dim a()
Dim n as Integer
Private Sub DeleteArray(x(),ByVal k )
for n=k to ______(1)_________
______(2)_________
next
ReDim Preserve x(n-1)
End Sub
Private Sub Command1_click()
n=0
If Ubound(a)>0 Then
n=Val(InputBox("请输入要删除的第几个元素(0-10):"))
End If
if n<=0 and n<=10 then_______(3)___________
End Sub
Private Sub From_Activate()
_________(4)______________
For n=0 to 10
a(n)=Int(Rnd*100)
next n
End Sub

第1个回答  推荐于2017-09-08
Option Explicit
Dim a()
Dim n as Integer

Private Sub DeleteArray(x(),ByVal k )
for n=k to Ubound(x)-1
x(n)=x(n+1)
next
ReDim Preserve x(n-1)
End Sub

Private Sub Command1_click()
n=0
If Ubound(a)>0 Then
n=Val(InputBox("请输入要删除的第几个元素(0-10):"))
End If
if n<=0 and n<=10 then DeleteArray a,n
End Sub

Private Sub From_Activate()
ReDim a(10)
For n=0 to 10
a(n)=Int(Rnd*100)
next n
End Sub本回答被提问者采纳
相似回答