I am almost finished a project in work but I need code to convert from binary to decimal. Can anyone help?
Printable View
I am almost finished a project in work but I need code to convert from binary to decimal. Can anyone help?
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