• 0

Visual Basic I/O pointer question


Question

Using Visual Basic 6.0

I have set up a connection to a file like so

  Quote
Dim fso As New FileSystemObject, mFile As File

Set mFile = fso.GetFile("C:\cushion_size.txt")

Set mTxtStream = mFile.OpenAsTextStream(ForWriting)

For i = 1 To 50

      ' Get a random value between 0 and 1.

      aValue = Rand(0, 3)

      ' Add the value to the chart

      mTxtStream.Write (aValue & "-")

Next i

mTxtStream.Write ("EOF")

Call mTxtStream.Close

How do i set the pointer for the position of where i want to read in a file? For example, i have a file that looks like this:

2-3-1-4-2-3-1-2-0-2-4-2-1-3-0-1-1-2-EOF

I want to read the first number (2, position 1 in the file), note where the next - is (position 2), read the next number (3, 3rd position), note the next -....

and so on.

Link to comment
https://www.neowin.net/forum/topic/263137-visual-basic-io-pointer-question/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Sorry.... that was for .NET.

Using the FSO, you can only read sequentially.

You would need to use the Open statement to open the file for Random access. Then you can use Seek.

Open

http://msdn.microsoft.com/library/default....l/vastmOpen.asp

Seek

http://msdn.microsoft.com/library/default....l/vastmseek.asp

Edited by weenur
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.