Results 1 to 2 of 2

Thread: binary to Decinal and Hexidecimal

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    3

    Post

    Having big probs writing a vb program that converts a binary number to Decimal and Hexidecimal. if you can help let me know.

    Also could you tell me how to set the properties.

    Thanks.

    Sarah Jamerson

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Hello AnimalCub,

    Try this source

    Private Sub Form_Load()
    Dim Q As String
    Dim N As Integer
    Dim Antwoord As Double

    Q = "1010" 'the binary value

    Antwoord = 0
    For N = 0 To Len(Q) - 1
    Antwoord = Antwoord + Val(Mid(Q, Len(Q) - N, 1)) * (2 ^ N)
    Next
    MsgBox Antwoord 'answer decimal
    MsgBox Hex(Antwoord)'answer hexadecimal
    End Sub


    Be nice to the animals!

    Michelle.

Posting Permissions

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



Click Here to Expand Forum to Full Width