1 |
2 |
Reference: Jessica Cao http://forums.asp.net/p/1086952/1625783.aspx
1 |
2 |
Option Compare Database Private Sub Form_Current() If Me.NewRecord Then Me.NameofTable = "" Else Me.NameofTable.SetFocus Me.NameofTable.Requery Me.NameofTable = Me.NameofTable.ItemData(Forms(0).CurrentRecord - 1) End If End Sub Private Sub NameofTable_Click() ' at this point, cbx text = cbx value If Me.NewRecord Or Me.NameofTable.ListIndex = -1 Then Me.nameoftabledum = Trim(Me.NameofTable) DoCmd.RunCommand acCmdSaveRecord Else If Me.NameofTable.ListIndex <> Forms(0).CurrentRecord - 1 Then DoCmd.GoToRecord , , acGoTo, Me.NameofTable.ListIndex + 1 End If End If End Sub Private Sub NameofTable_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 46 Then If Me.NameofTable.SelLength < Len(Me.NameofTable.Value) Then ' delete part of the text Else ' delete record Dim m As Integer m = Forms(0).CurrentRecord DoCmd.RunCommand acCmdDeleteRecord Me.NameofTable.Requery Forms(0).Requery If m > 1 Then m = m - 1 DoCmd.GoToRecord , , acGoTo, m End If End If End Sub
Function ProcessRSSItem() As String Dim rssURL As String = "http://www.abc.com/rss.rss" Dim myRequest As WebRequest = System.Net.WebRequest.Create(rssURL) Dim myResponse As WebResponse = myRequest.GetResponse() Dim rssStream As Stream = myResponse.GetResponseStream() Dim rssDoc As New XmlDocument() rssDoc.Load(rssStream) Dim nsmg As New XmlNamespaceManager(rssDoc.NameTable) nsmg.AddNamespace("dc", "http://purl.org/dc/elements/1.1/") Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item") Dim title As String = "" Dim link As String = "" Dim description As String = "" Dim i As Integer = 0 Dim numItems As Integer = 1 Dim sb As New System.Text.StringBuilder Dim rssDetail As XmlNode Do Until numItems = 10 rssDetail = rssItems.Item(i).SelectSingleNode("dc:language", nsmg) Console.WriteLine(rssDetail.InnerText.ToString()) If rssDetail.InnerText.Equals("en-US") Then rssDetail = rssItems.Item(i).SelectSingleNode("title") If rssDetail.Equals(Nothing) = False Then title = rssDetail.InnerText Else title = "" End If rssDetail = rssItems.Item(i).SelectSingleNode("link") If rssDetail.Equals(Nothing) = False Then link = rssDetail.InnerText Else link = "" End If rssDetail = rssItems.Item(i).SelectSingleNode("description") If rssDetail.Equals(Nothing) = False Then description = rssDetail.InnerText Else description = "" End If sb.Append("" + title + "
") numItems = i + 1 End If i = i + 1 Loop Return sb.ToString End Function
") sb.Append(description + "