1,453
社区成员
发帖
与我相关
我的任务
分享
Sub jjj()
'比较速度很快的
Dim a(30000000) As Byte, b(30000000) As Byte
b(90000) = 123
If StrComp(a, b) <> 0 Then MsgBox "不相等"
End Sub
Dim a$(), b$()
If Join(a, ";") = Join(b, ";") Then MsgBox "数组相同"
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
Dim A() As Byte
Dim B() As Byte
Dim strPath As String
Dim lngLen As Long
Dim lngTickCount As Long
Command1.Enabled = False
strPath = "E:\个人文件\学习文件\vb.pdf" '该PDF为高级VB编程,大小10080KB(10M)
lngLen = FileLen(strPath)
ReDim A(lngLen - 1)
ReDim B(lngLen - 1)
Debug.Print lngLen 'lngLen=10321246 千万级别的
Open strPath For Binary As #1
Get #1, , A
Close #1
B = A
B(UBound(A)) = 12
lngTickCount = GetTickCount
If StrConv(A, vbUnicode) <> StrConv(B, vbUnicode) Then
Debug.Print "两个数组不相同!"
Else
Debug.Print "两个数组相同!"
End If
Debug.Print "共耗时:" & GetTickCount - lngTickCount & "毫秒" '用时437毫秒
Command1.Visible = True
End Sub