J
Joergen Bech
Basically, I want to convert hex values in the range
"00000000" to "FFFFFFFF" to a signed, 32-bit Integer
value.
In VB6, I could just write lngValue = Val(hexstring$).
In VB.Net, I seem to be forced to do something like
---snip---
Private Function HexToInteger(ByVal hexValue As String) As Integer
If hexValue.ToLower.StartsWith("&h") Then
hexValue = hexValue.Substring(2)
End If
Dim value As Long = Long.Parse(hexValue,
Globalization.NumberStyles.HexNumber)
If value > Integer.MaxValue Then
value = value - 4294967296&
End If
Return CType(value, Integer)
End Function
---snip---
Have I overlooked a function in the framework?
Surely there is a faster/shorter/better way?
TIA,
Joergen Bech
"00000000" to "FFFFFFFF" to a signed, 32-bit Integer
value.
In VB6, I could just write lngValue = Val(hexstring$).
In VB.Net, I seem to be forced to do something like
---snip---
Private Function HexToInteger(ByVal hexValue As String) As Integer
If hexValue.ToLower.StartsWith("&h") Then
hexValue = hexValue.Substring(2)
End If
Dim value As Long = Long.Parse(hexValue,
Globalization.NumberStyles.HexNumber)
If value > Integer.MaxValue Then
value = value - 4294967296&
End If
Return CType(value, Integer)
End Function
---snip---
Have I overlooked a function in the framework?
Surely there is a faster/shorter/better way?
TIA,
Joergen Bech