网站建设资讯

NEWS

网站建设资讯

vb点虐 去除重复值 vb删除重复字符的处理

vb点虐 去掉重复数组怎么做?

Dim array1() As String

成都创新互联公司专业成都网站设计、成都网站建设,集网站策划、网站设计、网站制作于一体,网站seo、网站优化、网站营销、软文营销等专业人才根据搜索规律编程设计,让网站在运行后,在搜索中有好的表现,专业设计制作为您带来效益的网站!让网站建设为您创造效益。

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

VB中如何删除数组变量中重复的元素?

Private Function NewArray(ByRef b() As Integer)

Dim Temp() As Integer

Dim H As Integer, I As Integer, J As Integer, K As Integer

Dim IsNew As Boolean

H = UBound(b())

ReDim Temp(0) '如果你原数组元素数量是万个级别的,就直接ReDim Temp(H),下面 ReDim Preserve Temp(K) 去掉

Temp(0) = b(0)

For I = 0 To H

IsNew = True

For J = 0 To K

If Temp(J) = b(I) Then

IsNew = False

Exit For

End If

Next J

If IsNew Then

K = K + 1

ReDim Preserve Temp(K)

Temp(K) = b(I)

End If

Next I

ReDim b(K)

For I = 0 To K

b(I) = Temp(I)

Next I

Erase Temp()

End Function

'调用

'dim b() as integer

'dim I as integer

'dim OutputStr as String

'redim b(Ubound(a()))

'for I=0 TO Ubound(a())

' b(I)=a(I)

'next I

'NewArray(b())

'返回的b()为除重后的数组,可以根据你的需要显示、输出数组a()、b()。

VB.Net去除数组中重复的字符的元素?

比如数组a。里面有5个值,其中有3个是重复的?

如果这样的话,很好办哦。

新建一个数组b,然后遍历要去除的数组a,

从a中把每一个都取出来,和新建的b里面的去比,如果有相同的,则不放入b,

否则就放入数组b,直到循环结束。


当前标题:vb点虐 去除重复值 vb删除重复字符的处理
文章地址:http://cdweb.net/article/ddsdgjh.html