|
-
Oct 5th, 2000, 01:13 PM
#1
Thread Starter
Fanatic Member
-
Oct 5th, 2000, 01:34 PM
#2
_______
<?>
Code:
Option Explicit
Option Compare Text
Private Sub Form_Load()
Dim myArr() As Variant, myLine As String
Dim i As Integer, intNum As Integer
intNum = FreeFile
'
'open file
Open "C:\my documents\myfile.txt" For Input As intNum
Do While Not EOF(intNum)
i = i + 1
ReDim Preserve myArr(1 To i) As Variant
Line Input #intNum, myLine
If myLine Like "*character*" Then
i = i - 1
Else
myArr(i) = myLine
myArr(i) = Trim(myArr(i))
End If
Loop
Close #intNum
'open file
Open "c:\my documents\myfile.txt" For Output As intNum
For i = 1 To UBound(myArr)
Print #intNum, myArr(i)
'list box is optional just for display
' List1.AddItem myArr(i)
Next
Close #intNum
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 5th, 2000, 02:29 PM
#3
Addicted Member
The following might help, but I haven¡¯t tried it. There may be mistakes. Let¡¯s wait for others¡¯ comments.
Code:
-----------------------------------------
Option Explicit
Dim strTextFile As String
Dim strCharacters As String
Dim strText As String
Dim strTextLine As String
Dim intFileNo As Integer
Private Sub Form_Load()
strTextFile = ¡°MyFile.txt¡±
strCharacters = ¡°MyCharactersToFind¡±
intFileNo = FreeFile
Open strTextFile For Input As #intFileNo
Do Until Eof(intFileNo)
Line Input #intFileNo, strTextLine
If Left$(strTextLine, Len(strCharacters)) <> strCharacters Then
strText = strText & strTextLine & Chr$(13) & Chr$(10)
End If
Loop
Close intFileNo
intFileNo = FreeFile
'This will overwrite the original text file. If the original is to be preserved, use another file name.
Open strTextFile For Output As #intFileNo
Print #intFileNo, strText
Close intFileNo
End Sub
--------------------------------------
Visual Basic Professional 6.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|