Imports System
Imports System.Runtime.InteropServices
Namespace Test
Public Class Test
<StructLayout(LayoutKind.Explicit)> _
Private Structure Shorts2Float
<FieldOffset(0)> _
Public s1 As UInt16
<FieldOffset(2)> _
Public s2 As UInt16
<FieldOffset(0)> _
Public f As Single
End Structure
Public Shared Sub Main()
Dim s1 As UInt16 = Convert.ToUInt16(16455)
Dim s2 As UInt16 = Convert.ToUInt16(44564)
Dim s2f As Shorts2Float = New Shorts2Float
s2f.s1 = s1
s2f.s2 = s2
Dim f As Single = s2f.f
Debug.WriteLine("{0}", s2f.f.ToString())
End Sub
End Class
End Namespace