Community discussion forum

Convert Decimal Integer Values to Binary String in VB

This is a comment thread discussing Convert Decimal Integer Values to Binary String in VB6
  • 9 years ago

    This thread is for discussions of Convert Decimal Integer Values to Binary String in VB.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 2 years ago

    or may be a one liner like...

     

    Dim binaryString As String = Convert.ToString(numberToConvert, 2)

    Use PadLeft(n, "0") for required minimum length(n) of the output string.

    so it would look like

    Dim binaryString As String = Convert.ToString(numberToConvert, 2).PadLeft(n, "0")

    Prashant

     

  • 2 years ago

    The title (now edited) should have read 'in VB6'

  • 2 years ago

    Dim Number As Integer
    Dim BS As String

    Number = Val(Text1.Text)
    BS = ""
    While Number > 0
        BS = Number Mod 2 & BS
        Number = Number \ 2
    Wend
    Text2.Text = BS








  • 1 year ago

    Hi DoctorMahdi,

    How do I put BS into an array before display it into text2.text.  Thank you.

Post a reply

Enter your message below

Sign in or Join us (it's free).