Click here to Skip to main content
15,903,388 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen12-Dec-16 8:44
professionalEddy Vluggen12-Dec-16 8:44 
GeneralRe: INI - read multiline! Pin
User 989707412-Dec-16 8:59
User 989707412-Dec-16 8:59 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen12-Dec-16 11:37
professionalEddy Vluggen12-Dec-16 11:37 
GeneralRe: INI - read multiline! Pin
User 989707414-Dec-16 4:45
User 989707414-Dec-16 4:45 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen14-Dec-16 6:17
professionalEddy Vluggen14-Dec-16 6:17 
GeneralRe: INI - read multiline! Pin
User 989707414-Dec-16 6:29
User 989707414-Dec-16 6:29 
GeneralRe: INI - read multiline! Pin
User 989707414-Dec-16 6:43
User 989707414-Dec-16 6:43 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen14-Dec-16 7:08
professionalEddy Vluggen14-Dec-16 7:08 
That's not a valid* XML format; forget about how you want it to look, the format is simply there to provide structure to load and save from.
VB
' create new stuff
Dim newEntry As New MyMemoEntry
newEntry.CreatedOn = DateTime.Now
newEntry.Location = "Home, sweet home"
newEntry.Header = "How to build a decent chicken-soup"
newEntry.Memo = "Call Mom and say you want chicken-soup"

Dim notherEntry As New MyMemoEntry
notherEntry.CreatedOn = DateTime.Now
notherEntry.Location = "Home, sweet home"
notherEntry.Header = "How to build a decent noodle-soup"
notherEntry.Memo = "Call Mom and say you want noodle-soup"

Dim testEntry As New MyMemoEntry
testEntry.CreatedOn = DateTime.Now.AddDays(-2)
testEntry.Location = "The restaurant at the end of the Universe"
testEntry.Header = "Eat more soup"
testEntry.Memo = "I forgot the reason"

' add new stuff to list
Entries.Add(newEntry)
Entries.Add(notherEntry)
Entries.Add(testEntry)
Gives you valid XML like below;
XML
<?xml version="1.0"?>
<ArrayOfMyMemoEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="space">
  <MyMemoEntry>
    <CreatedOn>2016-12-14T18:54:25.0337545+01:00</CreatedOn>
    <Location>Home, sweet home</Location>
    <Header>How to build a decent chicken-soup</Header>
    <Memo>Call Mom and say you want chicken-soup</Memo>
  </MyMemoEntry>
  <MyMemoEntry>
    <CreatedOn>2016-12-14T18:54:25.0337545+01:00</CreatedOn>
    <Location>Home, sweet home</Location>
    <Header>How to build a decent noodle-soup</Header>
    <Memo>Call Mom and say you want noodle-soup</Memo>
  </MyMemoEntry>
  <MyMemoEntry>
    <CreatedOn>2016-12-12T18:54:25.0337545+01:00</CreatedOn>
    <Location>The restaurant at the end of the Universe</Location>
    <Header>Eat more soup</Header>
    <Memo>I forgot the reason</Memo>
  </MyMemoEntry>
</ArrayOfMyMemoEntry>
..accessing the items in a list by date would not be hard either this way;
VB
For Each item As MyMemoEntry In Entries _
    .Where(Function(ent As MyMemoEntry) As Boolean
               Return ent.CreatedOn.Date = DateTime.Today
           End Function)
    MessageBox.Show(item.Header)
Next
You can filter on any of the other fields in a similar way.

--edit
It is valid to confuse stuff more, as any XML-validator will tell you. It would also be abusing the format, as items representing the same thing are supposed to have the same element-name.

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: INI - read multiline! Pin
User 989707414-Dec-16 7:29
User 989707414-Dec-16 7:29 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen14-Dec-16 10:46
professionalEddy Vluggen14-Dec-16 10:46 
GeneralRe: INI - read multiline! Pin
User 989707415-Dec-16 0:36
User 989707415-Dec-16 0:36 
GeneralRe: INI - read multiline! Pin
User 989707415-Dec-16 0:38
User 989707415-Dec-16 0:38 
GeneralRe: INI - read multiline! Pin
Richard MacCutchan15-Dec-16 1:42
mveRichard MacCutchan15-Dec-16 1:42 
GeneralRe: INI - read multiline! Pin
User 989707415-Dec-16 4:37
User 989707415-Dec-16 4:37 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen15-Dec-16 5:00
professionalEddy Vluggen15-Dec-16 5:00 
GeneralRe: INI - read multiline! Pin
User 989707415-Dec-16 5:09
User 989707415-Dec-16 5:09 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen15-Dec-16 8:35
professionalEddy Vluggen15-Dec-16 8:35 
GeneralRe: INI - read multiline! Pin
User 989707417-Dec-16 1:27
User 989707417-Dec-16 1:27 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen17-Dec-16 23:46
professionalEddy Vluggen17-Dec-16 23:46 
GeneralRe: INI - read multiline! Pin
User 989707418-Dec-16 0:14
User 989707418-Dec-16 0:14 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen18-Dec-16 1:16
professionalEddy Vluggen18-Dec-16 1:16 
GeneralRe: INI - read multiline! Pin
User 989707418-Dec-16 7:41
User 989707418-Dec-16 7:41 
GeneralRe: INI - read multiline! Pin
User 989707419-Dec-16 1:57
User 989707419-Dec-16 1:57 
GeneralRe: INI - read multiline! Pin
Eddy Vluggen19-Dec-16 5:15
professionalEddy Vluggen19-Dec-16 5:15 
GeneralRe: INI - read multiline! Pin
User 989707419-Dec-16 5:18
User 989707419-Dec-16 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.