I'm converting code from VBA and I need to confirmed proof about the behavior of the Val function in order to faithfully reproduce it in .Net.
The issue is this line of VBA code
lHexNum = Val("&h" & HexNum) ' HexNum = 3B05000004F137
Is producing this output
323895
Which should be this,
16612521184391480
but I don't know why it isnt.
I have used 2 methods in .Net which both confirm the expected output of 16612521184391480 (as well as using a simple hex calculator).
Convert.ToInt64(HexNum, 16);
and
Microsoft.VisualBasic.Conversion.Val("&h" + HexNum);
However, I still need to perfectly replicate the actual output from the VBA program which right now gives the 323895 output.
The only reasoning I can find is if I remove the 3B05 from the HexNum I then get matching output. Since I cannot test this against enough live data to be 100% sure this works in all cases I cannot use this hack.
Does anyone have references or more information on how and why an Access 2003 application is getting the 323895 output from the Val function and why even the matching Microsoft.VisualBasic.Conversion.Val method cannot get the same output?