What is a web request?A web request is an http connection from your computer to another website or file online.
Example. Lets say we have this page:
http://www.example.com/c.php?count=1
Where count represents a simple counter, you can alter the values either by accesing the page and using the GUI, or by entering a link like this "http://www.example.com/c.php?count=2", this should make the counter proceed to 2.
So how can we do this with a WebRequest?
Its just as simple as this one line of code:
The webRequest code is after the "=".So what we did here was that we accesed a certain page, changed a few values and waited for the response just to be sure it worked.
I recommend you to always wait for the response, because most of the times if you don't it doesn't work properly.
Like so if we want we can change the page's counter to whatever.Lets say we have like a textbox named txtNum.We could do something like this:
Example. Lets say we have this page:
http://www.example.com/c.php?count=1
Where count represents a simple counter, you can alter the values either by accesing the page and using the GUI, or by entering a link like this "http://www.example.com/c.php?count=2", this should make the counter proceed to 2.
So how can we do this with a WebRequest?
Its just as simple as this one line of code:
Dim Response As Net.HttpWebResponse = Net.WebRequest.Create("http://www.example.com/c.php?count=2").GetResponse
The webRequest code is after the "=".So what we did here was that we accesed a certain page, changed a few values and waited for the response just to be sure it worked.
I recommend you to always wait for the response, because most of the times if you don't it doesn't work properly.
Like so if we want we can change the page's counter to whatever.Lets say we have like a textbox named txtNum.We could do something like this:
Private Sub txtNum_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNum.TextChanged
Dim Response As Net.HttpWebResponse = Net.WebRequest.Create("http://www.example.com/c.php?count=" & CInt(txtNum.Text)).GetResponse
End Sub
This is a fairly easy job.I will post more advanced stuff later on.
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου