How to send information to a web page with Inet control
The purpose of this article is explain how to send informations to a web page with an HTML-Form and Inet control. Really easy.
Original Author: Sebastiano Pallaro
Code
How to send information to <% Private
a web page with Inet control
Sending information to a web page with VB is really simple. You must only use
the Inet control and you application will be able to communicate with a web
site.
On this small tutorial I will suppose that we need an is-update-aviable-check
routine.
The first step is to build the web page that must receive the information. The
page must know the version number of the program and, in addition, the
registration-key of the program.
Here is the ASP page that check the version:
‘ Suppose that “B” is the
new version of our application.
if request.form(“Version”)
<> ”B” then
response.write “to_app”
‘ Hey, you must update!
else
response.write “ok”
‘ All ok.
end if
‘ With registration key you
can do all you want, for example put it into a database to track users
‘ updates… he he he good for privacy :-]
‘ …
%>
Now we only need to add to our program the
check-routine.
On a form put an Inet control (Inet1) and
add this code, for example, on the click event of a button:
‘ …
Dim strUrl As
String
Dim strFormData As
String
‘ Suppose that the version of
our app is “A”
strFormData = "Version=A&Key=123ABC"
strUrl = "The address of the prev.. ASP
page"
Inet1.url = strUrl
Inet1.Execute strUrl, "POST", strFormData, _
"Content-Type:
application/x-www-form-urlencoded"
‘ …
Sub Inet1_StateChanged(ByVal State As
Integer)
Dim strTemp As
String
If State = 12
Then ‘ If operation is
completed
strTemp = Inet1.GetChunk(32000)
strTemp = Trim(strTemp)
If
strTemp = “to_app” then
MsgBox
“You must update the application!”
ElseIf
strTemp = “ok” then
MsgBox
“No updates aviable”
Else
MsgBox
“Unknow response”
End If
End If
End Sub
As you can see this is only a silly little example,
but with this you can understand how to sending informations to a web-page in a
easy way.
Remember that you must URL-Encode each byte you send to the page and that some
special chars may lost during encoding.
That's all, folks
Hope this tutorial help you!
SebaMix
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.