VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 340,165 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 3,951 people online right now. Registration is fast and FREE... Join Now!




Get the selling price of an eBay Item

Returns a string representation of the price of an eBay item.

Submitted By: RodgerB
Actions:
Rating:
Views: 2,279

Language: VB.NET

Last Modified: December 11, 2007
Instructions: 1) Copy and Paste the Function into a Class.
2) Read how to call the function below.

Snippet


  1.     ''' <summary>
  2.     ''' Gets the price of the ebay item getting sold.
  3.     ''' </summary>
  4.     ''' <param name="URL">The URL to get the price from.</param>
  5.     ''' <returns>A String Result of the cost of the item.</returns>
  6.     ''' <remarks></remarks>
  7.  
  8.  
  9. Public Function getEbayPrice(ByRef URL As String) As String
  10.     ' Declare the variables
  11.     Dim wrq As Net.WebRequest = Net.WebRequest.Create(URL)
  12.     Dim wrp As Net.WebResponse = wrq.GetResponse()
  13.     Dim sr As IO.StreamReader = New IO.StreamReader(wrp.GetResponseStream())
  14.  
  15.     Dim Line As String = sr.ReadLine()
  16.  
  17.     ' Loop through and find the HTML line with the value we need.
  18.     ' When we find it, we will remove the text we don't need, resulting
  19.     ' in the selling price.
  20.     Do Until Line Is Nothing
  21.         If Line.Contains("DetailsCurrentBidValue") Then
  22.             Line = Line.Remove(0, InStr(Line, "DetailsCurrentBidValue") + 47)
  23.             Line = Line.Remove(InStr(Line, "<") - 2)
  24.             sr.Close()
  25.             wrp.Close()
  26.             Return Line
  27.         End If
  28.         Line = sr.ReadLine
  29.     Loop
  30.  
  31.     ' Clean Up.
  32.  
  33.     sr.Close()
  34.     wrp.Close()
  35.  
  36.     ' Return False because we didn't find the value.
  37.     Return False
  38. End Function
  39.  
  40. ' Example usage of the function.
  41. MessageBox.Show(getEbayPrice("http://cgi.ebay.com/Cute-BFF-LOL-BRB-Chat-Texting-Hot-Topic-Emo-T-Shirt-Tee_W0QQitemZ120192899461QQihZ002QQcategoryZ63869QQssPageNameZWDVWQQrdZ1QQcmdZViewItem"))

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month