vb.net清除数组 vb 清空数组
利用VB.NET编写:已知数组A=Array(7,6,5,1,8,5,3,9,4),编写一程序,删除数组中值为x(例如为3)...
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
VB.Net去除数组中重复的字符的元素?
比如数组a。里面有5个值,其中有3个是重复的?
如果这样的话,很好办哦。
新建一个数组b,然后遍历要去除的数组a,
从a中把每一个都取出来,和新建的b里面的去比,如果有相同的,则不放入b,
否则就放入数组b,直到循环结束。
vb.net去掉重复数组怎么做?
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
标题名称:vb.net清除数组 vb 清空数组
分享URL:http://scyanting.com/article/docjcgg.html