First, thanks to Paula for putting me on the right track to I hope eventually getting a solution to my original problem. Here is the code that is throwing me for a loop....
ReDim aryVin(2)
aryVin = brReader.ReadBytes(2)
SizeVIN = (aryVin(0) + aryVin(1) * 256) - 4
RecNumber3 = SizeVIN + 3
Numbytes = RecNumber3 - 4 + 1
A = ""
ReDim aryVin(Numbytes - 1)
aryVin = brReader.ReadBytes(Numbytes)
A = ASCIIEncoding.ASCII.GetString(aryVin, 0, Numbytes)
fsStream.Close()
brReader.Close()
This is what is happening, if I step through the code so that the A = line is the last statement executed, the first time an empty string is returned and there are only 510 array positions filled out of 6370 (Numbytes). If I then put the execution cursor back to the second Redim statement without executing the Close lines 126 array positions are filled and A has information that I would expect to see. When I put the cursor back to the second Redim statement and execute 3 more times I get respectively 62, 30, and 14 array positions filled with A having expected data. It looks like each time through adds more data from the stream. When I put the cursor back to the second Redim and execute again, Visual Studio crashes. Since the number of bytes put into the array each time decreases by close to a binary amount, I tend to think this is where the problem lies. Any ideas on what I am doing wrong Why isn't the entire binary file being loaded into the array the first time through and why does it take another time through the code to get expected data in the A variable This problem has plagued me all week and I really appreciate any help!!!!!

Newbie with VB^ to .NET problem revisited
PatrickL
If I do that, I only get the first two bytes of the stream. After the first two bytes are read, I need to then read the rest of the stream and stick the bytes into a variable. The byte array does have a length property in VB, by the way. The funny thing is I am now using a For loop to run .....
Dim k As Integer
Dim B As String = ""
Dim aryBytes(7) As String
For k = 1 To 8
ReDim aryVin(Numbytes - 1)
aryVin = brReader.ReadBytes(Numbytes)
A = ASCIIEncoding.ASCII.GetString(aryVin, 0, aryVin.Length)
aryBytes(k - 1) = A
Next
For k = 0 To 7
B = aryBytes(k)
Next
A = ""
A = B
This way I seem to be getting the whole stream into a string. However, the data is not everything that is in the file. It does not make sense that ALL of the stream is not being stored into the byte array the very first time through.
jmparks
I'll try to help again...but I might not know what I am talking about :o)
Anyway...I'm not sure you need this:
SizeVIN = (aryVin(0) + aryVin(1) * 256) - 4
RecNumber3 = SizeVIN + 3
Numbytes = RecNumber3 - 4 + 1
Can you try:
ReDim aryVin(2)
aryVin = brReader.ReadBytes(2)
A = ""
A = ASCIIEncoding.ASCII.GetString(aryVin, 0, aryVin.Length)
fsStream.Close()
brReader.Close()
Does the byte array in VB have a length property