'''這個(gè)函數(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}

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、拱墅ssl等。為近千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的拱墅網(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) '這個(gè)index就是b數(shù)組在a數(shù)組的位置,下標(biāo)從0開始,不過記得處理下逗號,因?yàn)檫@時(shí)候是字符串。'''如果index小于0說明沒有匹配內(nèi)容End Sub 現(xiàn)在說明下ByteArrayToString為什么要在字符串開頭加個(gè)",",如果不加,可能出現(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
先把strA排序,
ind = 2
if len(strA) = 0 then return
strB(1) = strA(1)
for each s in strA
if (strA(ind) strA(ind - 1) then
count = 0
strB(ind) = strA(ind)
else
strB(ind) = strA(ind - 1)
end if
ind = ind + 1
next s
vb語法忘了。。。大概是這么個(gè)意思吧。。。。 排序N LOG N,后面是線性的N,所以總共是NLOGN
Public?Class?Form1
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?a()?As?Byte?=?System.IO.File.ReadAllBytes("record.db")
For?Index?As?Integer?=?a.GetLowerBound(0)?To?a.GetUpperBound(0)?-?3
If?a(Index)?=?56?AndAlso?a(Index?+?1)?=?57?AndAlso?a(Index?+?2)?=?58?AndAlso?a(Index?+?3)?=?59?Then
Debug.Print(Index.ToString)?'輸出byte串位置
End?If
Next
End?Sub
End?Class
剛學(xué),不知道有沒有直接在數(shù)組中搜索一串元素的方法。
文章題目:vb.net數(shù)組查找,c語言數(shù)組搜索
網(wǎng)頁路徑:http://chinadenli.net/article44/dsgdihe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、企業(yè)建站、營銷型網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、響應(yīng)式網(wǎng)站、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)