How to send information to a web page with Inet control
![Visual Basic 6, or VB Classic Visual Basic 6, or VB Classic](https://www.fortypoundhead.com//assets/img/icons/v7/vb6.png)
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.