tags:

views:

15

answers:

0

I'm trying to read a binary file 2 characters at a time and see if it equals a value. I can not assign a value to the variable I want it to compare to the read value. For example, I want it to stop at the hex value 0x1188, so I'm doing:

Dim fs As FileStream = New FileStream(filepath, FileMode.Open)
Dim r As BinaryReader = New BinaryReader(fs)
Dim buffer As Int16
Dim targetVal as Int16

targetVal = &H1188 //error 'constant expression not representable in type Short'
//This also doesn't work: targetVal = Convert.toInt16(&H1188)
Try
        While (True)
            buffer = r.ReadInt16()
            If (buffer.Equals(targetVal)) Then
                MsgBox("Found")
            End if
        End While
Catch ex As Exception
    Console.WriteLine(ex)
    r.Close()
    fs.Close()
End Try

How can I do this correctly?