求助
VB中如何将数字3032215713转为十六进制? 需要处理大数Private Sub Command1_Click()
test = dectohex(3032215713#)
MsgBox test'结果为:B4BBF0A1
End Sub
'***************************************************************
'函数名称:10-->16进制转换
'***************************************************************
Function dectohex(ByVal hugenum As String) As String
Do While Len(hugenum) > 2
dectohex = Hex(Val(Right(hugenum, 4)) Mod 16) & dectohex
For I = 1 To 4
hugenum = half(hugenum)
Next
Loop
dectohex = Hex(Val(hugenum)) & dectohex
End Function
'***************************************************************
'函数名称:取半
'***************************************************************
Function half(ByVal X As String) As String '
X = 0 & X
Dim I As Long
ReDim result(2 To Len(X)) As String
For I = 2 To Len(X)
result(I) = CStr(Val(Mid(X, I, 1)) \ 2 + IIf(Val(Mid(X, I - 1, 1)) Mod 2 = 1, 5, 0))
Next
half = Join(result, "")
If Left(half, 1) = "0" Then half = Right(half, Len(half) - 1)
End Function 好长的代码,看不懂,对VB不感兴趣 谢谢老大!有些代码一时间还搞不明白,下来慢慢学习。根据老大的提示,本人想了一个简单一点的,不知可不可以?
Private Sub Command1_Click()
Dim Y As Double, XAs String
Y= 3032215713#
Do WhileY>10000
X = Hex(Val(Right(Y, 4)) Mod 16) &X
Y = Int(Y/ 16)
Loop
X = Hex(a) &X
MsgBox X
End Sub
页:
[1]