Public Function DecToBin(InByte As Integer) As String
Dim Float As Single
Dim i As Integer
'Copywrite (c) 2004 Randy Gamage
'This routine takes a byte value (0-255) as an input,
'and returns a string containing the binary representation
'of that number. Example:
' DecToBin(4) = "00000100"
DecToBin = ""
If InByte < 0 Or InByte > 255 Then Exit Function
For i = 1 To 8
Float = CSng(InByte) / CSng(2)
InByte = InByte \ 2
If Float = InByte Then
DecToBin = "0" & DecToBin
Else
DecToBin = "1" & DecToBin
End If
Next i
End Function