Example - Seek Function

  1. ' Suppose you have a file test.txt inside a d:\temp directory, containing this text: "This is a test. Only a test."

    ' This example cycles through the Line of text and returns the character positions of each period.

    ' Using the example file, it returns positions 17 and 30.

     

    Sub Main()

    1. Dim myFile As String

      myFile = "d:\temp\test.txt"

      MsgBox "Reading " & myFile & " for searching."

      Open myFile For Input As #1

      Do While Not EOF(1)

      1. myChar = Input (1,#1)

        ' MsgBox myStr

        myLocation = Seek (1)

        If myChar = "." Then

        1. MsgBox "Found a " & myChar & " at location " & myLocation

        End If

      Loop

      Close 1

    End Sub