Private Sub Command1_Click()
MsgBox Dec2Bin(1024)
End Sub

Function Dec2Bin(ByVal n As Long) As String
Do Until n = 0
    If (n Mod 2) Then Dec2Bin = "1" & Dec2Bin Else Dec2Bin = "0" & Dec2Bin
    n = n \ 2
Loop
End Function