I just tried to wrap the above Long->Hex solution into a sub, but got a weird compile error. So I pasted just the sample code into my sub like so:
B4X:
Sub LongToHexStr(L As Long) As String
Dim bc As ByteConverter
Dim val(1) As Long
Val(0) = 856987458515 '<<<<<<<<<<<
Log(bc.HexFromBytes(bc.LongsToBytes((Val))))
End Sub
Thanks MaFu. You mean square brackets? Made no difference. But I did discover the problem after a good night's sleep ... I have a function called Val() elsewhere in my program!
What misled me was that the error message pointed at the line using array variable Val(0). If the declaration had been flagged as Dupe Def then it would have been clearer.