Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject 1

Status
Not open for further replies.

bdfigler

Programmer
Oct 12, 2001
58
0
0
US
I am using FileSystemObject to open, edit and create text files from VB. I have a couple questions:

1. Is there a way to find out how many lines are in the text file just opened?
2. Is this the best way to read/edit an ini file for my own application?
3. Is FileSystemObject the best way to access text files on the user's computer or should I be using VB intrinsic methods? I still haven't figured out where to get a comprehensive list of vb intrinsic methods.

Thanks. -Brad
 
2. FAQ222-1198

I lost my list of others. I think they are close on the list.

Wil Mead
wmead@optonline.net

 
Hope this helps ......

1.
This may not be the bast way to get a line count using FSO but it is a way.

'************************************************
Private Sub Form_Load()
Dim oFSO As New Scripting.FileSystemObject
Dim oTextFile As Scripting.TextStream

Set oTextFile = oFSO.OpenTextFile(App.Path & "\test.txt")
MsgBox getLineCount(oTextFile, oTextFile.Line)
End Sub

Private Function getLineCount(oTextFile As Scripting.TextStream) As Long
Dim sDummy As String
sDummy = oTextFile.ReadAll
getLineCount = oTextFile.Line
End Function
'************************************************

2.
I would use the GetPrivateProfileString and WritePrivateProfileString API functions to access an .ini file, although Microsoft has deemed these obsolete in favor of writing to the registry.

3.
Microsoft had a very good reference book for VB5 called the Visual Basic 5.0 Language Reference, maybe there is one for 6.0.

-MattU
 
Thanks Matt. I am using pretty much the same thing as your GetLineCount function. It's not TOO slow, but it seems like a lot of extra cycles just for the convenience of a progress bar...

I've gotta learn how to use the registry :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top