Access/VBA Library


Returns a String containing the value of the specified item.


INI_GetValue( index [, default] )
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.

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), _
    ' Skip trailing characters of buffer
    INI_GetValue = Left$(buffer, length)
End Function

See also

  • GetPrivateProfileString