|
▼kein さん:
>10進数を2進数に高速に変換したいのですが
変換はあまり得手ではないのですが、試しに
16進数表記になおして、この1文字を4ケタの 0/1 に表記しなおす
関数を考えてみました。速くはないかもですが、簡単です (^^
Function toBin(num&) As String
Dim ss$, i&
ss = Hex$(num)
ReDim zz(1 To Len(ss)) As String
For i = 1 To Len(ss)
Select Case Mid$(ss, i, 1)
Case "0": zz(i) = "0000"
Case "1": zz(i) = "0001"
Case "2": zz(i) = "0010"
Case "3": zz(i) = "0011"
Case "4": zz(i) = "0100"
Case "5": zz(i) = "0101"
Case "6": zz(i) = "0110"
Case "7": zz(i) = "0111"
Case "8": zz(i) = "1000"
Case "9": zz(i) = "1001"
Case "A": zz(i) = "1010"
Case "B": zz(i) = "1011"
Case "C": zz(i) = "1100"
Case "D": zz(i) = "1101"
Case "E": zz(i) = "1110"
Case "F": zz(i) = "1111"
End Select
Next
toBin = Join(zz, "")
End Function
|
|