Results 1 to 20 of 22

Thread: Convert Decimal To Binary

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location

    Lightbulb DecimalToBinary

    Thanks for reply. This is the sub for DecimalToBinary.
    Can anyone find out what went wrong?


    ' Function to Convert Decimal to Binary (To CELL ID)
    Public Function DecimalToBinary(DecimalNum As Long) As String
    Dim tmp As String
    Dim n As Long
    n = DecimalNum
    tmp = Trim(Str(n Mod 2))
        n = n \ 2
    Do While n <> 0
        tmp = Trim(Str(n Mod 2)) & tmp
        n = n \ 2
        Loop
    DecimalToBinary = tmp
    End Function
    Last edited by Aussiebear; 04-23-2023 at 04:25 PM. Reason: Adjusted the code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •