views:

11

answers:

0

Hello,

I am working on a test project for an RSS reader. I am using Chilkat's module for .NET 3.5. What I am trying to do is this:

For each item in the RSS feed, I want to dynamically create some controls (labels) that contain stuff like the title, the link and the publication date.

The problem is that only the first control comes up "rssTitle", but not the rest and it's definitely not creating the rest, nor cycling through the RSS items.

Any ideas where I'm wrong in my code?

Imports Chilkat
Public Class Form1
Dim rss As New Chilkat.Rss
Dim success As Boolean
Dim rssTitle As New Label
Dim rssLink As New Label
Dim rssPubDate As New Label
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    success = rss.DownloadRss("http://www.engadget.com/rss.xml")
    If success <> True Then
        MessageBox.Show(rss.LastErrorText)
        Exit Sub
    End If

    Dim rssChannel As Chilkat.Rss
    rssChannel = rss.GetChannel(0)
    If rssChannel Is Nothing Then
        MessageBox.Show("No channel found.")
        Exit Sub
    End If

    Dim numItems As Long
    numItems = rssChannel.NumItems
    Dim i As Long

    For i = 0 To numItems - 1
        Dim rssItem As Chilkat.Rss
        rssItem = rssChannel.GetItem(i)

        Me.Controls.Add(rssTitle)
        With rssTitle
            .Name = "rssTitle" & Me.Controls.Count.ToString + 1
            .Text = "Title: " & rssItem.GetString("title")
            .Left = 12
            .Top = 12
        End With

        Me.Controls.Add(rssLink)
        With rssLink
            .Name = "rssLink" & Me.Controls.Count.ToString + 1
            .Text = "Link: " & rssItem.GetString("link")
            .Left = 12
            .Top = 12
        End With

        Me.Controls.Add(rssPubDate)
        With rssPubDate
            .Name = "rssPubDate" & Me.Controls.Count.ToString + 1
            .Text = "Pub date: " & rssItem.GetString("pubDate")
            .Left = 12
            .Top = 12
        End With

    Next

End Sub
End Class    

I'm grateful for any help.

Thanks!