Bodoora,
I'm really sorry, you will have to explain the problem in more detail, I don't fully understand what it is you want to print out!!
The code I gave you should loop through the file and print out every occurence of a word in brackets if you put all of the words into an array.
If what you want is not to print out the word GLOSS then just do an If .. Then statement to check for the word:
Option Explicit
Dim strLine As String
'Array to hold all the words
Dim strWord() As String
Private Sub Form_Load()
ReDim strWord(1)
Dim a As Integer
'A counter to record UBound of strWord Array
a = 0
Open "C:\source.txt" For Input As #1
'Loop through File
While Not EOF(1)
Line Input #1, strLine
If ((InStr(1, strLine, "(")) And (InStr(1, strLine, ")"))) Then
'Make strWord array bigger and store word in last position of array
ReDim Preserve strWord(UBound(strWord) + 1)
strWord(a) = Mid(strLine, InStr(1, strLine, "(") + 1, (Val(InStr(strLine, ")")) - Val(InStr(strLine, "(") + 1)))
'Increament counter
a = a + 1
End If
strLine = ""
Wend
Close #1
Open "C:\destination.txt" For Output As #1
'Loop through array
For a = 0 To UBound(strWord)
'If word at position a is not GLOSS then print out the word
If Trim(UCase(strWord(a))) <> "GLOSS" Then Print #1, strWord(a)
Next
Close #1
End Sub
Enter your message below
Sign in or Join us (it's free).