PrivateProfileString Long Key Values

J

John Jost

I recently read several postings on how to create a GetINISetting function
that would replace the System.PrivateProfileSetting function, which is
limited to 255 characters. The function shown retrieved a long string value,
which helped me out a lot. How can this be modified to 1) write to the INI
file to append a new INI Key value that is longer than 255 characters or
replace an existing INI Key value with a new value, that is longer than 255
characters?

The original function was...
Function getIniString(file As String, section As String, key As String)
Dim nr As Long
Dim curLine As String

nr = FreeFile

Open file For Input As nr
' read until section is found
Do Until EOF(nr) Or LCase(curLine) = "[" & LCase(section) & "]"
Line Input #nr, curLine
Loop

' read until end of file or key is found
Do Until EOF(nr)
Line Input #nr, curLine
' key found?
If LCase(curLine) Like LCase(key) & "=*" Then
' yes -> outta here
getIniString = Mid(curLine, Len(key) + 2)
Exit Do
End If
Loop
Close nr
End Function


Thanks in advance for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top