'''這個(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}
創(chuàng)新互聯(lián)主要從事網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)開州,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220
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開始,不過記得處理下逗號(hào),因?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)致查詢位置錯(cuò)誤,匹配了a的位置
先把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
你是不是應(yīng)該對(duì)最大值和最小值賦初值(比如把 r(1) 賦給最大值和最小值)呢?不然最小值默認(rèn)初始值是‘0’,后面的判斷就不起作用了。你可以加個(gè)斷點(diǎn)試試,他們的初始值是多少。。。
Sub?Find(ByRef?Obj?As?DataGridView,?Optional?ByVal?value?As?String?=?Nothing,?Optional?ByVal?cellIndex?As?Integer?=?1)
For?Each?i?As?DataGridViewRow?In?DataGridView1.Rows
If?value?Is?Nothing?OrElse?value?=?""?Then
i.Visible?=?True
Else
Try
If?i.Cells(cellIndex).Value?IsNot?Nothing?Then?i.Visible?=?i.Cells(cellIndex).Value?=?value
Catch?ex?As?Exception
End?Try
End?If
Next
End?Sub
Find(DataGridView1, "張三",1)