<pre> strReturnedString = Space$(255) ' buffer set aside for the API call
' To tell API how much space is available (API is too dumb to work it out for itself)
intSize = Len(strReturnedString)
Dim i As Integer
For i = 1 To 10
Next i
intCharsReturned = apiGetPrivateProfileString(strSect, strKey, _
"", strReturnedString, intSize, strFile)
If intCharsReturned = 0 Then ' Didn't find the value
strPPS = "" ' so return an empty string
' return only the significant characters
strPPS = Left(strReturnedString, intCharsReturned)
End If

There's something funny going on in or near apiGetPrivateProfileString.

Reproduced above a is section of code that obtains a set of colour vales (three RGB triplets) from my INI file.

I set up a Click- event on my userform to force it to re-obtain the colours and repaint the screen.

I open the INI file in Notepad, change the settings, choose File, Save, Alt-Tab to my form and click - nothing changes! Odd!????

I single-step through the code; sometimes it changes, sometimes it doesn't.

I make several essays trying to narrow it down - make several changes in Notepad and save after each one, THEN click - no change.

For a while it seemed as if only CLOSING the INI file from NotePad would force data to be re-written and re-obtained through apiGetPrivateProfileString, but then even that wasn't guaranteed. Re-opening the INI file in Notepad via a double-click in Explorer seems to force the apiGetPrivateProfileString to re-read the hard disk drive for values.

It's really odd. You can see that I've inserted a token DoEvents loop to try to flush buffers. Nada.

I don't have an answer, and probably you don't either.

But at least the next person to stumble across apiGetPrivateProfileString in a search for the truth might see this note wrapped in a bottle .....