VB怎样删除数组元素

VB怎样删除数组元素

删除数组元素只能用于动态数组,否则元素只能清零(整型)或清空(字符)
如数组a

清0 a(0)=0
清空 a(0)=""

动态数组清空:erase a
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2018-05-18
Private Sub Form_Load()
Dim a(4) As Integer
a(0) = 0
a(1) = 1
a(2) = 2
a(3) = 3

For i = 0 To UBound(removearray(a, 2)) - 2
Debug.Print removearray(a, 2)(i)
Next

End Sub

Private Function removearray(a() As Integer, index As Integer)
j = 0
For i = 0 To UBound(a) - 1
If i <> index Then
a(j) = a(i)
j = j + 1
End If

Next
removearray = a()
End Function本回答被提问者和网友采纳
第2个回答  2021-05-12

相似回答