Search Tools Links Login

A Binary Printing with only 10 lines of code !


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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 105 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.