0

I'm trying to read two matrix from a binary file (256x256x2) but couldn't do it without iterating 256x256x2 times which takes too long. For now I just want to check the data and make sure it's corect (not only zeros). This is what I have:

Dim msg As String
Dim b(256 * 256 * 2) As Byte
Dim i As Int32
Dim reader As New BinaryReader(File.Open(path, FileMode.Open))
b = reader.ReadBytes(b.Length)
For i = 0 To b.Length
    msg = msg & ", " & b(i)
Next
TextBox1.Text = msg

The data on the matrix are just numbers (0-255).

What's the best way to save the data to an array, if possible with the format

array[matrixno][row][column]

because later I will need to find specific values of the array based on its position.

PS. I'm using the old Visual Studio 2003 because that's what I have available.

Thanks

Edit:

Figured out what was taking long was actually displaying all the bytes, problem solved!

Molx
  • 6,816
  • 2
  • 31
  • 47
  • 3
    Visual Studio 2010 and 2012 both have free version (search for Visual Studio Express). You're depriving yourself of a lot of advanced and new features by using 2003 (which is .NET 1.1). LINQ would be something potentially **very** useful for what you're trying to do, and you would need at least VS 2008 to use it. – Tim Aug 12 '13 at 18:18
  • 1
    Yes, console I/O is very slow, you should use it only for debugging purposes. – Giulio Franco Aug 13 '13 at 20:01
  • 1
    1. You could enter your solution as an answer, and accept that one later. 2. Consider getting VB Express 10, it´s free, and probably includes all that you need. – TheBlastOne Aug 13 '13 at 20:04

1 Answers1

0

Almost two years later, it's time to take this off the unanswered list.

The loop worked just fine, the problem was printing every single value read instead of simpling saving it to a variable.

Lesson learned (long ago): Printing takes time.

Molx
  • 6,816
  • 2
  • 31
  • 47