新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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
结果为22种不同的和值。
'''这个函数功能就是用来把数组转为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}
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