Results 1 to 2 of 2

Thread: converting binary to decimal

  1. #1

    Thread Starter
    Junior Member roars's Avatar
    Join Date
    Jun 2000
    Location
    Northern Ireland
    Posts
    19
    I am almost finished a project in work but I need code to convert from binary to decimal. Can anyone help?

  2. #2
    Guest
    Try this:

    Code:
    Private Function Bin(ByVal sBinary As String) As Long
    
        Dim I As Integer
        For I = 0 To Len(sBinary) - 1
        If Mid(sBinary, Len(sBinary) - I, 1) = "1" Then Bin = Bin + (2 ^ I)
        Next
        
    End Function
    
    Private Sub Command1_Click()
    
        MyNum = Bin("100010111")
        MsgBox MyNum
    
    End Sub

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