Searching String in a formatted line

wz2jrz
04-23-2003, 01:50 PM
Hi,
I am reading a text file having formatting characters.

Several lines in the text file consists of tab(s) ...
I am looking for a search pattern say 'var' in a line consisting tabs.

there are two tabs before 'var' and one after
"[tab][tab]var[tab]" ---> this is how the line looks inside the text file

How can i search for such pattern in a formatted line?

or how can i search with the tabs included in the search pattern?

my basic objective is to search for only "[tab][tab]var[tab]" lines and NOT the ones like 'var_x' or 'num_var' or 'num_var_left'


My following code does not meet the desired logic..

'------Here's my code -------

Set fs = CreateObject("Scripting.FileSystemObject")
Set file_ptr = fs.OpenTextFile(wad_file, ForReading)

Do While file_ptr.AtEndOfStream <> True

mystring = file_ptr.readline
End If

If LCase(Left(Trim(mystring), 3)) = "var" Or InStr(Trim(mystring), " var ") > 0 Then
.... do something ....



thanks in advance for any help!
Nimish

Iceplug
04-23-2003, 01:54 PM
First of all, using the VB commands to open a file are much easier and efficient. :)


Open filename For Input As #1
Line Input #1, Text
If InStr(Text, vbTab & vbTab & "var" & vbTab) Then
Msgbox "Located"
End If
Close #1

Also, EOF(1) checks for the end of file. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum