Click here to Skip to main content
15,916,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys, i want to take exchange rate data from website to vb.net (txtbox) but idk i have tried many codes many times and still it does not work.
When i try only that command, i see all things about this address, but i want to see only exp EUR-USD.


Dim request As WebRequest = WebRequest.Create("https://www.iban.com/currency-converter")
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Dim datastream As Stream = response.GetResponseStream
Dim reader As New StreamReader(datastream)
Dim strdata As String = reader.ReadToEnd
TextBox1.Text = strdata


Please help me.

Thank you!

What I have tried:

Dim pos1 As Long, pos2 As Long, USD As String
Dim request As WebRequest = WebRequest.Create("https://www.iban.com/currency-converter")
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Dim datastream As Stream = response.GetResponseStream
Dim reader As New StreamReader(datastream)
Dim strdata As String = reader.ReadToEnd
'TextBox1.Text = strdata

pos1 = InStr(strdata, "EUR")
pos1 = InStr(pos1 + 1, strdata, "", vbTextCompare)
pos2 = InStr(pos2 + 9999, strdata, "", vbTextCompare)
USD = strdata.Substring(pos1, pos2)
TextBox1.Text = USD
Posted
Updated 15-Jun-21 0:09am

1 solution

You would need to use webscraping to get what you want, but it may still not work. Use the API that is provided IBAN Developers Center & API Documentation[^].
 
Share this answer
 
Comments
Richard MacCutchan 14-Jun-21 9:05am    
The issue is that you can only capture the information the the website makes available. so you need to analyse the complete response to your HTTP request to find the information that you are interested in. A much better way is to use the API that the site provides.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900