vb如何删除数组中的一个指定元素? 20
2个回答
展开全部
Dim a() As Integer
Private Sub Command1_Click()
Cls
ReDim a(9)
Dim i As Integer
For i = 0 To 9
a(i) = 10 + Int(Rnd * 90)
Print a(i);
Next
Print
Print
End Sub
Private Sub Command2_Click()
Dim i As Integer, f As Boolean
For i = 0 To UBound(a)
If a(i) = Val(Text1.Text) Then
f = True
Exit For
End If
Next
Dim j As Integer
For j = i To UBound(a) - 1
a(j) = a(j + 1)
Next
If f Then
ReDim Preserve a(UBound(a) - 1)
End If
For i = 0 To UBound(a)
Print a(i);
Next
Print
Print
End Sub
Private Sub Command1_Click()
Cls
ReDim a(9)
Dim i As Integer
For i = 0 To 9
a(i) = 10 + Int(Rnd * 90)
Print a(i);
Next
End Sub
Private Sub Command2_Click()
Dim i As Integer, f As Boolean
For i = 0 To UBound(a)
If a(i) = Val(Text1.Text) Then
f = True
Exit For
End If
Next
Dim j As Integer
For j = i To UBound(a) - 1
a(j) = a(j + 1)
Next
If f Then
ReDim Preserve a(UBound(a) - 1)
End If
For i = 0 To UBound(a)
Print a(i);
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询