Click to See Complete Forum and Search --> : Urgent!! How can I get a string from a specific position in a HTML file e.g line 50, 13-20 character


Kung Wu
February 6th, 2000, 07:52 AM
Urgent!! How can I get a string from a specific position in a HTML file e.g line 50, 13-20 characters

Cakkie
February 6th, 2000, 11:36 PM
dim myFile as string
dim myLine as integer
dim myString as string
dim myStringStart as integer
dim myStringEnd as integer
dim myLineCounter as integer
dim strData as string
dim ok as boolean

myFile = "c:\myhtml.html" 'file to examine
myLine = 50 'line to examine
myStringStart = 13 'starting position of string to get
myStringEnd = 20 'ending position of string to get
myLineCounter = 0 'counting lines
ok = false

open myFile for input as #1

do while (not(eof(1)) and not(ok))
myLineCounter = myLineCounter + 1
Line input #1, strData
if myLineCounter = myLine then 'if the read line is the one we need
myString = mid(myLine,myStringStart,myStringEnd - myStringStart)
ok = true
end if
loop

if ok then 'if we reached the line
msgbox "Retrieved " & myString
else 'in case the file did not contain myLine lines
msgbox "Retrieving string failed"
end if





Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.