by Eduardo B. Castro (1 Submission)
Category: Coding Standards
Compatability: VB Script
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
This procedure prints the binary code of a number on Immediate window.
Inputs
Num as Long
Assumes
You can easily change the procedure to a function for returning the binary code.
Code Returns
Nothing
Public Sub PrintBinary(Num As Long)
Dim j&, i&
j = 128
For i = 8 To 1 Step -1
If (Num And j) = 0 Then
Debug.Print "0";
Else
Debug.Print "1";
End If
j = j / 2
Next
End Sub