VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Binary Printing with only 10 lines of code

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

Rate A Binary Printing with only 10 lines of code

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

Download this snippet    Add to My Saved Code

A Binary Printing with only 10 lines of code Comments

No comments have been posted about A Binary Printing with only 10 lines of code. Why not be the first to post a comment about A Binary Printing with only 10 lines of code.

Post your comment

Subject:
Message:
0/1000 characters