GetItem Method  
 

Set the current news item to the specified item number.

Syntax

object.GetItem( ItemId )

Parameters

ItemId
An integer value which specifies item in the news feed channel.

Return Value

A value of zero is returned if the news item was selected. Otherwise, a non-zero error code is returned which indicates the cause of the failure. If the method fails, the value of the LastError property can be used to determine cause of the failure.

Remarks

The GetItem method is used to select the current news item in the feed. If this method is successful, the current news item is changed to the specified value and property values such as ItemLink and ItemText will be updated. If this method fails, the current news item is not changed.

The item number is an index into the list of available news items in the current news feed. The first news item is one, and it increments for each additional item in the feed. If ItemId parameter is zero or specifies a value larger than the number of items in the feed, this method will fail. The ItemId property returns the value of the currently selected news item.

If this method fails, it typically indicates that the ItemId parameter is invalid or that the feed does not contain any valid news items. The ItemCount property can be used to determine the number of items contained in the news feed channel.

Example

The following example accesses a remote feed and enumerates each news item, populating the contents of a ListBox control with its title.

Dim strFeed As String
Dim nIndex As Long
Dim nError As Long
    
strFeed = "http://sockettools.com/rss/news.xml"
ListBox1.Clear
    
nError = NewsFeed1.Open(strFeed)
If nError > 0 Then
    MsgBox NewsFeed1.LastErrorString, vbExclamation
    Exit Sub
End If
    
Label1.Caption = NewsFeed1.ItemCount & " news items, published on " & NewsFeed1.Published
    
For nIndex = 1 To NewsFeed1.ItemCount
    nError = NewsFeed1.GetItem(nIndex)
    If nError > 0 Then
        MsgBox NewsFeed1.LastErrorString, vbExclamation
        Exit For
    End If
    ListBox1.AddItem NewsFeed1.ItemTitle
Next

See Also

ItemCount Property, ItemId Property, Close Method, FindItem Method, Open Method, Parse Method