Read text files in directory+vb6.0

Hi,
How do I  loop in a directory to search .txt files and open them.I am using vb6.0


Regards
RIASAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Code to list all files in the folder. You can modify this to list only .txt file and open if required.

http://www.freevbcode.com/ShowCode.Asp?ID=1331

FindClose lFirstRet
APIAllFiles = sAns

End Function

Private Function StripNull(ByVal InString As String) As String

'Input: String containing null terminator (Chr(0))
'Returns: all character before the null terminator

Dim iNull As Integer
If Len(InString) > 0 Then
    iNull = InStr(InString, vbNullChar)
    Select Case iNull
    Case 0
        StripNull = InString
    Case 1
        StripNull = ""
    Case Else
       StripNull = Left$(InString, iNull - 1)
   End Select
End If

End Function

Public Function isDirectory(FileAttr As Long) As Boolean

Dim bAns As Boolean
Dim lDir As Long
Dim lHidden As Long
Dim lSystem As Long
Dim lReadOnly As Long

lDir = FILE_ATTRIBUTE_DIRECTORY
lHidden = FILE_ATTRIBUTE_HIDDEN
lSystem = FILE_ATTRIBUTE_SYSTEM
lReadOnly = FILE_ATTRIBUTE_READONLY
    
isDirectory = FileAttr = lDir Or FileAttr = _
    lDir + lHidden Or FileAttr = lDir + lSystem _
    Or FileAttr = lDir + lReadOnly Or FileAttr = _
    lDir + lHidden + lSystem Or FileAttr = _
    lDir + lHidden + lReadOnly Or FileAttr = _
    lDir + lSystem + lReadOnly Or _
    FileAttr = lDir + lSystem + lHidden + lReadOnly

End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
merowingerCommented:
check out this
dim objFSO
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder("D:\")

For Each file in objFolder.Files
	If Instr(ucase(Right(file,3)),"TXT") Then
		set objFile = objFSO.OpenTextFile(file)
		'continue processing
	End If
Next

Open in new window

0
RIASAuthor Commented:
Cheers mate
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.