大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'''这个函数功能就是用来把数组转为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}
我们提供的服务有:成都网站设计、网站制作、微信公众号开发、网站优化、网站认证、拱墅ssl等。为近千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的拱墅网站制作公司
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的位置
先遍历数组:
for i = 0 to Ubound(数组)
...
next
再把中间的...替换成:
if 数组(i) = 特定的字符 then msgbox "找到鸟,当前是:数组" 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语法忘了。。。大概是这么个意思吧。。。。 排序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
刚学,不知道有没有直接在数组中搜索一串元素的方法。