Hack Forums
[.NET] [VB.NET] Get USD Price of Bitcoin (no JSON) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [VB.NET] Get USD Price of Bitcoin (no JSON) (/showthread.php?tid=4690733)



[VB.NET] Get USD Price of Bitcoin (no JSON) - Lord.Baltimore - Feb 17, 2015

Hi !

I'm going to share a code made by me for get the official price of Bitcoin
from blockchain.info !

I call :

LBL_Stats_Price a label in my form !

The code :

Code
Public Class Form1
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
LBL_Stats_Price.Text = "Price of Bitcoin ( from blockchain.info ) : $" & (GetPrice()) & " USD"
      End Sub

      Function GetPrice() As String
        Dim request As New WebClient
        Return request.DownloadString("https://blockchain.info/fr/q/24hrprice")
      End Function
End Class

That's all !
Bye ! :)


* - Odus - Feb 17, 2015

Declare the web client outwith the function so you don't initialize each time the method is called.

Code
Private Function getPrice() As String
    Return String.Format("Price of 1 Bitcoin: ${0} USD", wc.DownloadString("https://blockchain.info/fr/q/24hrprice"))
End Function



* - DevNet - Feb 17, 2015

This is no better than "no JSON", if anything I'd say it's worse..


* - Lord.Baltimore - Feb 17, 2015

(Feb 17, 2015 12:25 PM)DevNet Wrote:  This is no better than "no JSON", if anything I'd say it's worse..

I searched a method for get the price without JSON !
But it's easy with JSON :)