十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
For i = 0 To 10 '假设数组长度为10
创新互联公司是一家企业级云计算解决方案提供商,超15年IDC数据中心运营经验。主营GPU显卡服务器,站群服务器,川西大数据中心,海外高防服务器,机柜大带宽、租用·托管,动态拨号VPS,海外云手机,海外云服务器,海外服务器租用托管等。
If a(i) = 3 Then
For j = i To 10 - 1
a(j) = a(j + 1)
Next j
ReDim Preserve a(10 - 1)
Exit For
End If
Next i
If i 10 Then
For k = 0 To 10 - 1
Print a(k)
Next
Else
For k = 0 To 10
Print a(k)
Next
End If
比如数组a。里面有5个值,其中有3个是重复的?
如果这样的话,很好办哦。
新建一个数组b,然后遍历要去除的数组a,
从a中把每一个都取出来,和新建的b里面的去比,如果有相同的,则不放入b,
否则就放入数组b,直到循环结束。
Dim array1() As String
Dim array2() As Boolean
Dim i As Integer
Dim j As Integer
Dim str1 As String = "a,c,c,c,a,b,c,d,f,eee,eee"
array1 = Split(str1, ",")
str1 = ""
ReDim array2(UBound(array1))
For i = 0 To UBound(array1)
array2(i) = False
Next
For i = 0 To UBound(array1) - 1
If array2(i) = False Then
For j = i + 1 To UBound(array1)
If array1(i) = array1(j) And array2(j) = False Then
array2(j) = True
End If
Next j
End If
Next i
For i = 0 To UBound(array1)
If array2(i) = False Then
str1 = str1 array1(i) ","
End If
Next i
If str1 "" Then
str1 = Strings.Left(str1, Len(str1) - 1)
End If