Ответить на сообщение
Вернуться к теме
Вы отвечаете на сообщение:
ник: Lukas Проверим, у меня тоже новая функция:
Public Declare Function apiTimeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long Public Function ToBinary3(ByVal Number As Long, Optional Digits As Long = 24) As String Dim Ret As String Dim i As Long Const ZERO As String = "0" Const ONE As String = "1" Ret = String(Digits, ZERO) If Number Then For i = Digits To 0 Step -1 If Number Mod 2 Then Mid$(Ret, i, 1) = ONE End If Number = Number \ 2 Next i End If ToBinary3 = Ret End Function Public Function DecToBin(ByVal DecNum As Long) As String If DecNum = 0 Then DecToBin = "0" Else DecToBin = "" Do Until DecNum = 0 If (DecNum Mod 2) Then DecToBin = "1" & DecToBin Else DecToBin = "0" & DecToBin DecNum = DecNum \ 2 Loop End Function Public Function Test() Dim i As Long Dim j As Long Dim start As Long Dim str As String Dim var As Variant For i = 0 To 5000000 'разгоним процессор i = i Next i For j = 1 To 10 DoEvents str = "" start = apiTimeGetTime For i = 0 To 100000 str = ToBinary3(i, 17) Next i Debug.Print "ToBinary3___=" & apiTimeGetTime - start & " ms", str DoEvents str = "" start = apiTimeGetTime For i = 0 To 100000 str = DecToBin(i) Next i Debug.Print "DecToBin____=" & apiTimeGetTime - start & " ms", str Debug.Print "-------------------------------------------" Next j End Function Результаты: ToBinary3___=485 ms 11000011010100000 DecToBin____=687 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=688 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=703 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=688 ms 11000011010100000 ------------------------------------------- ToBinary3___=578 ms 11000011010100000 DecToBin____=828 ms 11000011010100000 ------------------------------------------- ToBinary3___=500 ms 11000011010100000 DecToBin____=672 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=688 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=687 ms 11000011010100000 ------------------------------------------- ToBinary3___=485 ms 11000011010100000 DecToBin____=687 ms 11000011010100000 ------------------------------------------- ToBinary3___=484 ms 11000011010100000 DecToBin____=688 ms 11000011010100000 -------------------------------------------
Ваше имя:
Пароль:
Сообщение:
Прикрепить:
Для вставки смайлов в текст щелкните по значку.