Access/VBA Library

INI_GetSections

Returns a Collection of sections within the INI-file.

Syntax

INI_GetSections()
Return value

Collection : List of sections.

Code
Public Function INI_GetSections() As Collection
    Dim buffer As String
    Dim length As Long
    Dim sections
    ' Maak buffers
    buffer = Space$(MAX_BUF_SIZE)
    length = GetPrivateProfileString( _
                  vbNullString, _
                  vbNullString, _
                  "", _
                  buffer, _
                  Len(buffer), _
                  INI_Filename())
    ' sections are separated by a Null-character
    sections = Split(Left$(buffer, length), vbNullChar)
    ' The last section is also followed by a Null-char!
    ' So shorten the array by 1
    Set INI_GetSections = ArrayToCollection(sections, endIndex:=UBound(sections) - 1)
End Function

See also

  • GetPrivateProfileString
  • ArrayToCollection