Bitcoin Forum

Bitcoin => Project Development => Topic started by: Karim12 on May 28, 2018, 01:59:40 AM



Title: Adding BTC value in vb.net windows form applications
Post by: Karim12 on May 28, 2018, 01:59:40 AM
Hello guys, Is it possible to show the BTC value in a button or textbox in vb.net windows form application? I need it so bad.
Thanks


Title: Re: Adding BTC value in vb.net windows form applications
Post by: NeuroticFish on May 28, 2018, 05:33:08 AM
Hello guys, Is it possible to show the BTC value in a button or textbox in vb.net windows form application? I need it so bad.
Thanks


You have to make a http request to one of the exchanges, for example https://api.bitfinex.com/v1/pubticker/BTCUSD
Then you have to parse the response (json) and get the price (docs are here https://bitfinex.readme.io/v1/reference#rest-public-ticker)
Then you can set the text on the button.

Of course, you may have to refresh that value from time to time.


Title: Re: Adding BTC value in vb.net windows form applications
Post by: TryNinja on May 28, 2018, 03:57:47 PM
A simple example:

1. Install Json.net with NuGet: https://www.newtonsoft.com/json (https://www.newtonsoft.com/json);

2. Import it;
Code:
Imports Newtonsoft.Json.Linq

3. Use something like this:
Code:
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("https://api.coinmarketcap.com/v2/ticker/1/?convert=BTC")

Dim json As JObject = JObject.Parse(result)
TextBox1.Text = "$" + json.SelectToken("data").SelectToken("quotes").SelectToken("USD").SelectToken("price").ToString()