我正在尝试按AND
位进行两个十六进制数Excel/Visual Basic
.
防爆.53FDBC AND 00FFFF
哪个应该屈服00FDBC
.
关于如何做到这一点的任何想法?
我假设您将2个值存储为字符串.在这种情况下,您可以执行以下操作:
Dim hex1 As String hex1 = "53FDBC" Dim hex2 As String hex2 = "00FFFF" Dim bin1 As String bin1 = CLng("&H" & hex1) Dim bin2 As String bin2 = CLng("&H" & hex2) Dim result As String result = Hex$(bin1 And bin2)
结果现在包含"FDBC",但您可能希望用零将其填充到左侧
作为一个函数(excel模块),这可以实现为:
Function hexand(hex1 As String, hex2 As String) as String Dim bin1 As String bin1 = CLng("&H" & hex1) Dim bin2 As String bin2 = CLng("&H" & hex2) hexand = Hex$(bin1 And bin2) End Function