Search Tools Links Login

A Binary Printing with only 10 lines of code !

Posted: 2003-06-01
By: ArchiveBot
Viewed: 76

Filed Under:

Visual Basic 6

No attachments for this post


This procedure prints the binary code of a number on Immediate window.

Original Author: Eduardo B. Castro

Inputs

Num as Long

Assumptions

You can easily change the procedure to a function for returning the binary code.

Returns

Nothing

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


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.