Public Declare Function apiTimeGetTime Lib "winmm.dll" Alias "timeGetTime" () As Long
Public Function ToBinary2(ByVal Number As Long) As String
ToBinary2 = Oct$(Number)
ToBinary2 = Replace(ToBinary2, "0", "000")
ToBinary2 = Replace(ToBinary2, "1", "001")
ToBinary2 = Replace(ToBinary2, "2", "010")
ToBinary2 = Replace(ToBinary2, "3", "011")
ToBinary2 = Replace(ToBinary2, "4", "100")
ToBinary2 = Replace(ToBinary2, "5", "101")
ToBinary2 = Replace(ToBinary2, "6", "110")
ToBinary2 = Replace(ToBinary2, "7", "111")
End Function
Public Function ToBinary(ByVal Number As Long) As String
ToBinary = Number Mod 2
Do While Number > 0
Number = Number \ 2
ToBinary = ToBinary & Abs(Number Mod 2 > 0)
Loop
ToBinary = StrReverse(ToBinary)
If Len(ToBinary) > 1 Then ToBinary = Mid(ToBinary, 2)
End Function
Public Function Test()
Dim i As Long
Dim j As Long
Dim start As Long
Dim str As String
For i = 0 To 5000000 'Разгон процессора
i = i
Next i
For j = 1 To 10
str = ""
start = apiTimeGetTime
For i = 0 To 10000
str = ToBinary2(i)
Next i
Debug.Print "ShadowOfSun=" & apiTimeGetTime - start & " ms", str
str = ""
start = apiTimeGetTime
For i = 0 To 10000
str = ToBinary(i)
Next i
Debug.Print "Lukas____(3)=" & apiTimeGetTime - start & " ms", str
Debug.Print "-------------------------------------------"
Next j
End Function
|