先随机生成10个数,然后在text1中输入自己想删除的数 确认后删除那个数
温馨提示:答案为网友推荐,仅供参考
第1个回答 2020-07-22
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