Here is one way to do it:
- From the Toolbox under the All Windows Forms group, add a Label to your form
- Click once on the BasicLabel you have reading the custom length string
- In the Properties Window, click the lightening bolt to see the selection of event
- Double in the ValueChanged to get back to code
- Enter this code:
Label1.Text=ExtractString(BasicLabel1.Text)
- After the End Sub, enter this code:
Private Function ExtractString(ByVal s As String) As String
Dim bytes((s.Length / 2) - 1) As Byte
For i = 0 To (s.Length / 2) - 1
bytes(i) = Byte.Parse(s.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber)
Next
Dim StringLength As Integer = BitConverter.ToInt32(bytes, 0)
Dim StringResult As String = System.Text.Encoding.Default.GetString(bytes, 4, bytes.Length - 4)
Return StringResult
End Function