說明:MyItems.Item(11)是一個位元組型資料,Byte
我需要的是二進制的資料
請問下,我這段程式為什么要這樣來寫,請朋友給決議下,非常感謝
temp = MyItems.Item(11) Mod 256
For i = 5 To 0 Step -1
dd(i) = temp \ 2 ^ i
temp = temp Mod 2 ^ i
Next i
uj5u.com熱心網友回復:
什么意思啊?那個資料,在計算機內,不就是以“二進制”存盤的嗎。
看你貼的那段代碼,是想得到一個位元組數值的二進制碼字串?
如果是這樣,可以參考這段代碼:
Private Function GetBinText(ByVal lValue As Long) As String
Const s1 As String = "0000101001101111000"
Const s2 As String = "0125A4936DB7FEC8"
Dim i As Long, sBin As String, sHex As String
sHex = Hex$(lValue)
For i = 1 To Len(sHex)
sBin = sBin & Mid$(s1, InStr(1, s2, Mid$(sHex, i, 1)), 4)
Next i
GetBinText = sBin
End Function
'應用示例:
temp = GetBinText(MyItems.Item(11))
'如果你只要低位元組的低6位:
temp = Right$(GetBinText(MyItems.Item(11)), 6)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/153431.html
標籤:VB基礎類
上一篇:msflexgrid查詢輸出出錯
