I want to convert a decimal number to a hexadecimal number program, to convert a value beyond the long range to a hexadecimal number, is there a way, 20200430110900, how to become 125F477608B4
Code:
Public Function DEC_to_HEX(Dec As Currency) As String
Dim a As String
DEC_to_HEX = ""
Do While Dec > 0
a = CStr(Dec - 16 * Int(Dec / 16))
Select Case a
Case "10": a = "A"
Case "11": a = "B"
Case "12": a = "C"
Case "13": a = "D"
Case "14": a = "E"
Case "15": a = "F"
End Select
DEC_to_HEX = a & DEC_to_HEX
Dec = Int(Dec / 16)
Loop
End Function
Code:
Function LongToHexStr(LongV As String) As String
Dim js As Object
'dim Js As ScriptControl :Set js = New ScriptControl
Set js = CreateObject("ScriptControl")
js.Language = "javascript"
js.AddCode "var num = " & LongV & ";"
LongToHexStr = js.Eval("num.toString(16).toUpperCase()")
Set js = Nothing
End Function
Function LongToHexStr(LongV As String) As String
Dim js As Object: Set js = CreateObject("ScriptControl"): js.Language = "javascript"
LongToHexStr = js.Eval("var num=" & LongV & ";num.toString(16).toUpperCase()")
End Function