'''這個函數(shù)功能就是用來把數(shù)組轉(zhuǎn)為string的格式'''如byte()={1,2,3,4,5,6}轉(zhuǎn)化后變?yōu)?,1,2,3,4,5,6,"Function ByteArrayToString(bytes() As Byte) As String Dim s As String = "" For i As Integer = 0 To bytes.Length s = Convert.ToString(bytes(i)) "," Next Return “," sEnd Function Sub Search()Dim a as byte()={1,2,3,4,5,6}
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、網(wǎng)站空間、營銷軟件、網(wǎng)站建設(shè)、長安網(wǎng)站維護(hù)、網(wǎng)站推廣。
Dim b as byte()={2,3,4}
Dim astr As String = ByteArrayToString(a)Dim bstr As String = ByteArrayToString(b)Dim index As Integer = astr.IndexOf(bstr) '這個index就是b數(shù)組在a數(shù)組的位置,下標(biāo)從0開始,不過記得處理下逗號,因?yàn)檫@時候是字符串。'''如果index小于0說明沒有匹配內(nèi)容End Sub 現(xiàn)在說明下ByteArrayToString為什么要在字符串開頭加個",",如果不加,可能出現(xiàn)a="1,23,4,5,6,", b="3,4,5,",結(jié)果導(dǎo)致查詢位置錯誤,匹配了a的位置
先遍歷數(shù)組:
for?i?=?0?to?Ubound(數(shù)組)
...
next
再把中間的...替換成:
if?數(shù)組(i)?=?特定的字符?then?msgbox?"找到鳥,當(dāng)前是:數(shù)組"??i
Sub 和()
Dim Arr, Dic As Object, i, j, k
Set Dic = CreateObject("Scripting.Dictionary")
Arr = Array(5, 7, 11, 13, 17, 19)
For i = 0 To UBound(Arr)
For j = 0 To UBound(Arr)
For k = 0 To UBound(Arr)
Dic(Arr(i) + Arr(j) + Arr(k)) = ""
Next k
Next j
Next i
MsgBox Dic.Count
Set Dic = Nothing
End Sub
結(jié)果為22種不同的和值。