2013年8月8日木曜日

Dec2Hex : Excel で10進→16進変換

Excel で10進→16進変換をしようとするとアドインを追加する必要があるので、自分で作ってみたら簡単だった。

Function Dec2Hex(dec As Variant, Optional ByVal places As Integer = 4) As String
  Dec2Hex = Right(String(places, "0") + hex$(dec), places)
End Function

注) hex は Variant を、hex$ は String を返す。


Function Hex2Dbl(hex As String) As Double
  Hex2Dbl = CDbl("&H" + hex)
End Function

Function Hex2Lng(hex As String) As Long
  Hex2Lng = CLng("&H" + hex)
End Function


0 件のコメント: