Author | Message | Time |
---|---|---|
BoBBaGe | i use an ini for a config i have on one of my projects. one of the things i have to save/load is a multiline textbox (obviously with multiline text). on writing the ini, it writes the multiline "Code=lineblahblahblahblahblahblahblahblahblahblahblahblahblah lineblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah lineblahblahblah" which is wat i want its just on getting the ini to load, it only loads the first line "Code=lineblahblahblahblahblahblahblahblahblahblahblahblahblah" instead of all of the lines into the textbox i would like it to load all of the lines into the multiline textbox (txtCode.Text) which i have created can anyone help me on this? | August 17, 2003, 2:04 AM |
Grok | When writing your multiline text to the INI, replace the CRLFs with a relatively non-typable character, like chr(1). Then when reading the INI entries, replace the Chr(1)'s with CRLFs again. In this way, your multiline text will show in INI file as a single-line entry. This is required for ReadPrivateProfileString() to work correctly. Hope this helps. | August 17, 2003, 5:11 AM |
Camel | Here's what I used to use on my bot: [code]Function GS(ByVal Section As String, ByVal Name As String, Optional Default As String, Optional File As String = "Users.INI") As String Name = Replace(Name, "=", Chr(1)) Section = Replace(Section, "[", "!") Section = Replace(Section, "]", "!") GS = Space(MaxValLength) GS = Left(GS, GetPrivateProfileString(Section, Name, Default, GS, Len(GS), App.Path & "\" & File)) GS = Replace(GS, Chr(1), vbCr) GS = Replace(GS, Chr(2), """") End Function Sub SS(ByVal Section As String, ByVal Name As String, ByVal Value As String, Optional File As String = "Users.INI") Name = Replace(Name, "=", Chr(1)) Section = Replace(Section, "[", "!") Section = Replace(Section, "]", "!") If Not IsNumeric(Value) Then Value = Replace(Value, vbCrLf, vbCr) Value = Replace(Value, vbCr, Chr(1)) Value = Replace(Value, """", Chr(2)) Value = """" & Value & """" End If WritePrivateProfileString Section, Name, Value, App.Path & "\" & File End Sub[/code] | August 17, 2003, 5:39 AM |