當前位置:成語大全網 - 新華字典 - VB 挑出字符串數組中不同元素

VB 挑出字符串數組中不同元素

給妳個函數

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