Converting warnings when analyzing project

I have following code in my project

' s = String passed to the function
' String should be of type : "F0 01 02 00 04 F7"

Var i As Integer
Var rtn As Integer
Var length As Integer = s.CountFields(" ")
Var m As New MemoryBlock(length)
Var X As String

For i = 0 To length - 1
  m.Byte(i) = Val("&h" + s.NthField(" ", i+1))
Next

X = m.StringValue(0, length)
rtn = HP_InsertSysex(hphandle, time, X)
If rtn > HP_ERR_NONE Then ReportErrors("HPInsertSysex", rtn, currentMethodName)

Line m.Byte(i) = Val("&h" + s.NthField(" ", i+1))
Gives me this warning :
converting from Double to Integer causes a possible loss of precision, which can lead to unexpected results.
How to solve this conversion warning in my code ?
Thanks
Regards

Val returns a double.
You could use a different functions or cast with CType().

Mabe just skip the &h thing and val and use Integer.FromHex (hexValue As String) As Integer instead.

1 Like

Ok thanks very much.
Both the solutions are working.
I opted for the Integer.FromHex(hexvalue As String)