十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
'''这个函数功能就是用来把数组转为string的格式'''如byte()={1,2,3,4,5,6}转化后变为",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}
创新互联主要从事网站制作、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务开州,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务: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) '这个index就是b数组在a数组的位置,下标从0开始,不过记得处理下逗号,因为这时候是字符串。'''如果index小于0说明没有匹配内容End Sub 现在说明下ByteArrayToString为什么要在字符串开头加个",",如果不加,可能出现a="1,23,4,5,6,", b="3,4,5,",结果导致查询位置错误,匹配了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语法忘了。。。大概是这么个意思吧。。。。 排序N LOG N,后面是线性的N,所以总共是NLOGN
你是不是应该对最大值和最小值赋初值(比如把 r(1) 赋给最大值和最小值)呢?不然最小值默认初始值是‘0’,后面的判断就不起作用了。你可以加个断点试试,他们的初始值是多少。。。
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)