1樓:匿名使用者
private sub command1_click()
dim stra() as string, strb() as string, i, j, n as integer
stra = split("123,211,234324,43,4,123,43,211", ",") 'stra賦值bai
duredim strb(0)
strb(0) = stra(0) 'strb的第乙個元素賦值
for i = 1 to ubound(stra) '遍歷stra
for j = 0 to ubound(strb) '查詢zhi
是否已經包含在strb中
if stra(i) = strb(j) then exit for
next
if j > ubound(strb) then '如果沒dao包含
n = n + 1
redim preserve strb(n) '擴大數回組
strb(n) = stra(i)
end if
next
for i = 0 to ubound(strb) '顯示strb的所有答元素
print strb(i)
next
end sub
2樓:匿名使用者
function removeduplication(byref sourcearray()) as variant()
..dim returns()
..dim uboundreturns as integer:uboundreturns = -1
..dim i as integer, j as integer
..for i=0 to ubound(sourcearray)
....dim found as boolean:found=false
....for j=0 to uboundreturns - 1
......if (sourcearray(i) = returns(j)) then found = true
....next
....if (not found) then
......uboundreturns = uboundreturns + 1
......redim preserve returns(uboundreturns)
......returns(uboundreturns) = sourcearray(i)
....endif
..next
....removeduplication = returns
end function
3樓:匿名使用者
1、字典可以很好的解決問題。內
2、**如容
下:private sub command1_click()
on error resume next
dim stra(), strb(), dic as object, i as integer
stra = array("123", "123", "211", "234324", "43", "4", "43", "211")
set dic = createobject("scripting.dictionary")
for i = 0 to ubound(stra)
dic.add stra(i), i
next
redim strb(dic.count - 1)
i = 0
for each x in dic.keys
strb(i) = x
i = i + 1
next
msgbox "stra:" & join(stra, ",") & chr(10) & "strb:" & join(strb, ",")
end sub
vb字串陣列賦值問題,VB字串和字元陣列的賦值問題
dim strarray strarray array 姓名 性別 年齡 dim string 20 string 1 姓名 string 2 性別 string 3 年齡 與普通陣列賦值有什麼區別嗎?工程裡建立乙個模組,然後貼上下邊 public type a sname as string 6 ...
C字元陣列和字串陣列,在C中字元陣列和字串有什麼區別
實際上,字元陣列和普通陣列一樣,沒有本質區別。請大家注意陣列型別的含義 資料型別指的是陣列所包含的元素的型別,而不是陣列名的型別,陣列名永遠是乙個指標,指向第乙個元素的位址,即陣列首位址。字元陣列的每個元素都是char型別,整型陣列的每個元素都是int型別。scanf 和 printf 函式有一種格...
vb中有那個函式可以取出字串中兩個特定字母之間的字串
沒有直接實現你的要求的函式,要用多個函式結合才行。比如獲取ab之間的字串 s a b c a instr s,a b instr a 1,s,b ss mid s,a 1,b a 1 或者s a b c ss split split s,a 1 b 0 left a b c 5 取 a b c 字串...