Pirahnaplant
Well-known member
- Joined
- Mar 29, 2009
- Messages
- 75
- Programming Experience
- 3-5
Here is some code I am trying to use to read a UShort and UInteger from a filestream:
The problem is that it doesn't return the right value. Can anyone provide me with a function that works?
Edit: Nevermind, I figured it out, that code works fine.
VB.NET:
Private Function ReadUShort(ByVal fs As IO.FileStream) As UShort
Dim temp(1) As Byte
fs.Read(temp, 0, 2)
Dim v As UShort = temp(0)
v += temp(1) * 256
Return v
End Function
Private Function ReadUInteger(ByVal fs As IO.FileStream) As UInteger
Dim temp(3) As Byte
fs.Read(temp, 0, 4)
Dim v As UInteger = temp(0)
v += temp(1) * 256
v += temp(2) * 65536
v += temp(3) * 1677216
Return v
End Function
The problem is that it doesn't return the right value. Can anyone provide me with a function that works?
Edit: Nevermind, I figured it out, that code works fine.
Last edited: