Put this code in a module.

Code:
Public Function GetINIValue(ByVal Section As String, SearchFor As String) as String
    Dim Ini As String
    Dim SectStart As Long
    Dim StartPos As Long
    Dim EndPos As Long
    Dim Value As String
    Open "MyINIFile.ini" For Input As #1
        Ini = Input$(LOF(1), 1)
    Close #1
    SectStart = InStr(1, Ini, "[" & Section & "]")
    SectStart = SectStart + Len(Section) + 2
    StartPos = InStr(1, Ini, SearchFor)
    For n = StartPos To Len(Ini)
        If Asc(Mid$(Ini, n, 1)) < 30 Then
        EndPos = n: Exit For
        End If
    Next
    Value = Mid$(Ini, StartPos, EndPos - StartPos)
    Value = Right$(Value, Len(Value) - Len(SearchFor) - 1)
    GetINIValue = Value
End Function
Then you just call the function from your main program. The INI file my code is reading from looks like this:-

[general]
header=My Program
[linkoftheday]
url=www.theonion.com
caption=The Onion

"Section" is the bit in square brackets, "SearchFor" is the bit to... erm... search for. So, :-

Result = GetINIValue("linkoftheday", "url")

...would make Result = www.theonion.com

This code probably can't be modified to write INI settings, and there might be an easier way of reading AND writing INI files. I didn't need to write any settings so this is what I used.


[Edited by gfk on 06-08-2000 at 10:04 AM]