Results 1 to 20 of 22

Thread: Convert Decimal To Binary

Threaded View

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

    Question Convert Decimal To Binary

    Hello! I have a problem here. When I run this sub, the value in MsgBox is correct, but why there is difference when copy this value to Cell in Sheet1?
    I need the binary string to be fixed 32bit. If less, then have bit padding.

    Sub ConvDecCELLID()
    Dim CON_VAL As Double
    Dim IniVal, temp As String
    CON_VAL = 2 ^ 10 * 64
    IniVal = vbNullString
    With UserForm3
        Cells(18, 13).Formula = DecimalToBinary(.tbInput1.Value)
        IniVal = DecimalToBinary(.tbInput1.Value)
        IniVal = Right$(String(32, "0") & IniVal, 32)
        MsgBox (IniVal)
        .tbLAC.Text = Format(.tbInput2.Value / CON_VAL, 0)
        .tbCI.Text = .tbInput2.Value Mod CON_VAL
    End With
    end Sub

    Please help.
    Last edited by Aussiebear; 04-23-2023 at 04:24 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
  •