DrewDog_21
Nov 30th, 1999, 10:52 PM
Can somebody show me the syntaxt on how to read just one line of a text file and how to specify which line to read?
e.g. if I have a .ini file like
[PROGRAM NAME]
ODBC
Total_Fields = 6
what syntax should I use to return just the line Total_Fields = 6?
Thanks in advance
Andrew
Aaron Young
Dec 1st, 1999, 11:15 AM
If you're using an INI File Format you'd be better off using the GetPrivateProfileString API which is specificly for retrieving data from an INI File, eg.
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub Command1_Click()
Dim sBuff As String * 255
Call GetPrivateProfileString("PROGRAM NAME", "Total_Fields", "", ByVal sBuff, 255, "C:\MyINI.ini")
If Left(sBuff, 1) <> Chr(0) Then MsgBox Left(sBuff, InStr(sBuff, Chr(0)) - 1)
End Sub
Where MyINI.ini is the Name of your INI File.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net