EDN Admin
Well-known member
Hi all
Am I using the wrong terms to count the Category then count the Genre? because this is getting me lost.
I cant seam to use 0 to x.elements.Count, which I have used in some tutorials or am I phrasing it all wrong?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Category()
<span style="color:Blue; Dim output <span style="color:Blue; As XElement = <Value></Value>
<span style="color:Blue; Dim song <span style="color:Blue; As XElement = _
<SongList>
<Song>
<Info>
<Title>title 7</Title>
<Artist>artist 7</Artist>
</Info>
<Category>
<Genre>00<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>
<Song>
<Info>
<Title>title 9</Title>
<Artist>artist 9</Artist>
</Info>
<Category>
<Genre>90<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>
<Song>
<Info>
<Title>title 10</Title>
<Artist>artist 10</Artist>
</Info>
<Category>
<Genre>80<span style="color:Green; s</Genre>
<Genre>Rock</Genre>
</Category>
<Data>
</Data>
</Song>
</SongList>
<span style="color:Green; song = XElement.Load("c:songs.xml")
<span style="color:Blue; Dim newQ <span style="color:Blue; As IEnumerable(Of XElement) = _
<span style="color:Blue; From El <span style="color:Blue; In song...<Song>, g <span style="color:Blue; In El.<Category>.<Genre> _
<span style="color:Blue; Select El
<span style="color:Blue; Dim Cat_count <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Blue; Dim Gen_count <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Blue; For <span style="color:Blue; Each x <span style="color:Blue; As XElement <span style="color:Blue; In newQ.<Category>
<span style="color:Green; Dim Cat_count As Integer = 0 to x.Elements.Count()
<span style="color:Blue; For <span style="color:Blue; Each c <span style="color:Blue; As XElement _ <br/>
<span style="color:Blue; In newQ.<Category>.<span style="color:Blue; Skip(x.Elements.<span style="color:Blue; Count()).<Genre>
<span style="color:Green; Dim Gen_count As Integer = 0 - c.Elements.Count()
<span style="color:Blue; If output.Value.Contains(newQ.<Category>.<span style="color:Blue; Skip(Cat_count). _ <br/>
<Genre>.<span style="color:Blue; Skip(Gen_count).Value) <span style="color:Blue; Then
Gen_count = Gen_count + 1
<span style="color:Blue; Else
output.Add(newQ.<Category>.<span style="color:Blue; Skip(Cat_count). _ <br/>
<Genre>.<span style="color:Blue; Skip(Gen_count).Value)
<span style="color:Blue; End <span style="color:Blue; If
Cat_count = Cat_count + 1
<span style="color:Blue; Next
<span style="color:Blue; Next
MsgBox(output.Value)
[/code]
Thank you for your help!
Andy
<hr class="sig Currently working on my first VB Project - A music Player - until i am old enough to take programing at school Please be kind as I am only learning and I learn best by dissecting something, rebuilding it and asking questions
View the full article
Am I using the wrong terms to count the Category then count the Genre? because this is getting me lost.
I cant seam to use 0 to x.elements.Count, which I have used in some tutorials or am I phrasing it all wrong?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Category()
<span style="color:Blue; Dim output <span style="color:Blue; As XElement = <Value></Value>
<span style="color:Blue; Dim song <span style="color:Blue; As XElement = _
<SongList>
<Song>
<Info>
<Title>title 7</Title>
<Artist>artist 7</Artist>
</Info>
<Category>
<Genre>00<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>
<Song>
<Info>
<Title>title 9</Title>
<Artist>artist 9</Artist>
</Info>
<Category>
<Genre>90<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>
<Song>
<Info>
<Title>title 10</Title>
<Artist>artist 10</Artist>
</Info>
<Category>
<Genre>80<span style="color:Green; s</Genre>
<Genre>Rock</Genre>
</Category>
<Data>
</Data>
</Song>
</SongList>
<span style="color:Green; song = XElement.Load("c:songs.xml")
<span style="color:Blue; Dim newQ <span style="color:Blue; As IEnumerable(Of XElement) = _
<span style="color:Blue; From El <span style="color:Blue; In song...<Song>, g <span style="color:Blue; In El.<Category>.<Genre> _
<span style="color:Blue; Select El
<span style="color:Blue; Dim Cat_count <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Blue; Dim Gen_count <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Blue; For <span style="color:Blue; Each x <span style="color:Blue; As XElement <span style="color:Blue; In newQ.<Category>
<span style="color:Green; Dim Cat_count As Integer = 0 to x.Elements.Count()
<span style="color:Blue; For <span style="color:Blue; Each c <span style="color:Blue; As XElement _ <br/>
<span style="color:Blue; In newQ.<Category>.<span style="color:Blue; Skip(x.Elements.<span style="color:Blue; Count()).<Genre>
<span style="color:Green; Dim Gen_count As Integer = 0 - c.Elements.Count()
<span style="color:Blue; If output.Value.Contains(newQ.<Category>.<span style="color:Blue; Skip(Cat_count). _ <br/>
<Genre>.<span style="color:Blue; Skip(Gen_count).Value) <span style="color:Blue; Then
Gen_count = Gen_count + 1
<span style="color:Blue; Else
output.Add(newQ.<Category>.<span style="color:Blue; Skip(Cat_count). _ <br/>
<Genre>.<span style="color:Blue; Skip(Gen_count).Value)
<span style="color:Blue; End <span style="color:Blue; If
Cat_count = Cat_count + 1
<span style="color:Blue; Next
<span style="color:Blue; Next
MsgBox(output.Value)
[/code]
Thank you for your help!
Andy
<hr class="sig Currently working on my first VB Project - A music Player - until i am old enough to take programing at school Please be kind as I am only learning and I learn best by dissecting something, rebuilding it and asking questions
View the full article