Dim array1() As String
潼关ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
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
比如数组a。里面有5个值,其中有3个是重复的?
如果这样的话,很好办哦。
新建一个数组b,然后遍历要去除的数组a,
从a中把每一个都取出来,和新建的b里面的去比,如果有相同的,则不放入b,
否则就放入数组b,直到循环结束。
Erase 数组名
要注意,如果是固定数组,则所有元素的值被初始化(字符型为空字符串,数值型为0),数组的大小是不变的;如果是动态数组,则所有元素被删除,内存空间被回收,要重新ReDim才能使用。Private Sub Form_Click()Dim a(9) As Integer, i As IntegerRandomizePrint "清除前:"For i = 0 To 9 a(i) = Rnd * 100 Print a(i);NextPrintErase aPrint "清除后"For i = 0 To 9 Print a(i);NextPrintEnd Sub