【VBA】Convert binary to decimal

You can convert binary to decimal!

Use the following Worksheet function:
 Bin2Dec Function

PR

VBA Code

You can convert binary to decimal.

Option Explicit

Sub sampleProc()
    
    Dim targetNum As Long
    
    'Set "target binary"
    targetNum = 10101

    'Convert binary to decimal
    MsgBox WorksheetFunction.Bin2Dec(targetNum)
    
End Sub

Set “target binary“(Line 8).

Convert binary to decimal(Line 11).
※argument・・・Set “target binary“.

PR

Result

You converted binary to decimal!

Result
Result
PR

FYI No.1

Also, you can convert decimal to binary!

For more information, see the following article:

PR

FYI No.2

For more information about following, see the following official online manual:

Bin2Dec method” of “WorksheetFunction Object”


BIN2DEC Function

タイトルとURLをコピーしました