VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to send information to a web page with Inet control

by Sebastiano Pallaro (5 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

The purpose of this article is explain how to send informations to a web page with an HTML-Form and Inet control. Really easy.

Rate How to send information to a web page with Inet control

How to send information to
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"

    ‘ … 


Private
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


Download this snippet    Add to My Saved Code

How to send information to a web page with Inet control Comments

No comments have been posted about How to send information to a web page with Inet control. Why not be the first to post a comment about How to send information to a web page with Inet control.

Post your comment

Subject:
Message:
0/1000 characters