Access/VBA Library

INI_GetValue

Returns a String containing the value of the specified item.

Syntax

INI_GetValue( index [, default] )
Parameters
Name Type Description
index String Required. The index of the key in the INI-file (
.).
default String Optional. The value to be returned if the key does not exist.
Default: ""
Return value

String : The value of the key. If the key does not exists the default value is returned.

Code
Public Function INI_GetValue(ByVal index As String, _
                             Optional ByVal default As String = "") As String
    Dim buffer As String
    Dim length As Long
    
    buffer = Space$(MAX_BUF_SIZE)
    length = GetPrivateProfileString( _
                GetSectionFromIndex(index), _
                GetKeyFromIndex(index), _
                default, _
                buffer, _
                Len(buffer), _
                INI_Filename())
    ' Skip trailing characters of buffer
    INI_GetValue = Left$(buffer, length)
End Function

See also

  • GetPrivateProfileString