sam hollick

sam hollick

  • NA
  • 1
  • 1.8k

Writing to a file using For Each?

Aug 31 2010 3:45 PM
Hello Guys, usually i don't ask for help if I for VB.Net but I am actually stumped at the moment. 

Right, so I am making a program to edit files using the a DLL file called PackageIO (which is used for editing files). Now, What i need to do i right about 200+ values to a file just by clicking save. I did start just doing a save function for every value but that obviously got very tedious after several minutes.

I was wondering is there a way of using the For Each statement to save to a Hex location.

I have tried this so far and it doesn't work.....


Dim reader As New PackageIO.Reader(FilePath, Endian.Big)
       
 reader.Position = &H101

Dim Writer As New PackageIO.Writer(FilePath, Endian.Big)

For Each Value In reader.ReadBytes(27)
            Writer.Position = Value
            Writer.WriteSingle(dg.Item(0, 0).Value)
Next Value

Value after writer.position usually would have the &H then the hex location.
dg.item(0,0).value) is the Datagridview item from location 0, 0.

Seeing as I am using a DLL that some users or maybe most users will not know how to use. can someone please tell me my obvious mistake or show or tell me how to actually use the For Each statement to write to files.

Thanks Guys.