我想把一个长整形变量表示为十六进制数 并且格式为 00 00 00 00 这样strCardData = Format(Hex(TempCardNum), "00 00 00 00 ")我这样写的话 ,0到9都没有问题但是到10的时候就不对了本来应该显示00 00 00 0A的 但是实际只显示A谁能告诉我应该怎么做?
解决方案 »
- 请问怎样把屏幕的坐标倒转如正常情况x=0 Y=0,改成X=1024,Y=768 屏幕为(1024*768) 请绿豆回答
- 我是一名VB初学者,现在碰到一个问题需要各位高手指点!!急!!
- 紧急求助!!!!!
- 谁有用Inet发送短信息的代码???
- vb如何查询oracle服务器的时间啊?
- 请帮忙
- 求助
- 请教VB中的timer
- /*******************junglerover(灌木丛)的问题:(大家讨论)现在有些人明显在用程序回帖子混参与分,大家说他究竟想干什么?***************************/
- 十万火急,ic卡管理机软件设计的v.b实现方法
- 请问如何通过MSHTML.HTMLDocument获取到<a name="I" href="">的a对象?
- <%if rs("Price") = 0 then%>
b = Format(Right$(String$(8, Asc(0)), 8 - Len(Hex$(a))) & Hex$(a), "00 00 00 00")
Debug.Print b
Text1.Text = LongHEX(65535)下列代码必须放在“模块”里,而不能写在窗体里。
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Public Function LongHEX(ByRef pValue As Long) As Byte()
Dim tOutBytes() As Byte
Dim tOutBytes_Index As Byte
Dim tValueBytes() As Byte
Dim tValueBytes_Index As Byte
Dim tHEX_Bit As Byte
Dim tHEX_Hex As Boolean
ReDim tOutBytes(0 To 23)
ReDim tValueBytes(0 To 3)
CopyMemory tValueBytes(0), pValue, 4
For tValueBytes_Index = 0 To 3
tOutBytes_Index = tValueBytes_Index * 6
tHEX_Bit = tValueBytes(tValueBytes_Index) \ 16: tHEX_Hex = tHEX_Bit > 9
tOutBytes(tOutBytes_Index) = tHEX_Bit + 48 + (tHEX_Hex And 7)
tHEX_Bit = tValueBytes(tValueBytes_Index) Mod 16: tHEX_Hex = tHEX_Bit > 9
tOutBytes(tOutBytes_Index + 2) = tHEX_Bit + 48 + (tHEX_Hex And 7)
tOutBytes(tOutBytes_Index + 4) = &H20
Next
LongHEX = tOutBytes()
End Function
不要见笑:)
将函数For循环里的:tOutBytes_Index = tValueBytes_Index * 6
改为:tOutBytes_Index = (3 - tValueBytes_Index) * 6
Option Explicit
Private Sub Command1_Click()
Debug.Print FormatDisplayHex(10)
End SubFunction FormatDisplayHex(n As Long)
Dim i As Integer, Temp As String
For i = 1 To Len(CStr(Hex(n)))
Temp = Temp & "0" & Mid(CStr(Hex(n)), i, 1) & Space(1)
Next
For i = 1 To 4 - Len(CStr(Hex(n))) '不足4位
Temp = "00 " & Temp
Next
FormatDisplayHex = Temp
End Function
那么我把我最后使用的方法也跟大家分享一下啦!'''Function GeShiHua(St As String) As String
''' Dim Str1 As String, Str2 As String, Str3 As String
'''
''' If Len(St) > 8 Then
''' GeShiHua = ""
''' Exit Function
''' End If
''' Str1 = "00000000"
''' Str2 = Left(Str1, 8 - Len(St)) & St
''' For i = 1 To 8 Step 2
''' Str3 = Str3 & Mid(Str2, i, 2) & " "
''' Next
''' GeShiHua = Trim(Str3)
'''End Function 调用这个方法就可以了。