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.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
<p class="MsoNormal"><font face="Tahoma" size="2"><b>How to send information to a web page with Inet control<br> </b><br> 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.<br> On this small tutorial I will suppose that we need an is-update-aviable-check routine.<br> 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.<br> Here is the ASP page that check the version:</font></p> <p class="MsoNormal"><font face="Courier New" size="2"><font color="#800000"><span style="background-color: #FFFF00"><%</span></font><span style="mso-spacerun: yes"><br> </span><font color="#008000">‘ Suppose that “B” is the new version of our application.</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">if </font>request.<b>form</b>(“<b>Version</b>”) <> ”<b>B</b>” <font color="#0000FF">then</font><span style="mso-spacerun: yes"><br> </span>response.write “<b>to_app</b>” <font color="#008000">‘ Hey, you must update!</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">else</font><span style="mso-spacerun: yes"><br> </span>response.write “<b>ok</b>” <font color="#008000">‘ All ok.</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">end if</font><span style="mso-spacerun: yes"><br> </span><font color="#008000">‘ With registration key you can do all you want, for example put it into a database to track users<span style="mso-spacerun: yes"><br> </span>‘ updates… he he he good for privacy :-]<span style="mso-spacerun: yes"><br> </span>‘ …</font><br> <font color="#800000"><span style="background-color: #FFFF00">%></span></font></font><br> <br> <font face="Tahoma" size="2">Now we only need to add to our program the check-routine.<br> On a form put an Inet control (Inet1)<span style="mso-spacerun: yes"> </span>and add this code, for example, on the click event of a button:<span style="mso-spacerun: yes"> </span></font></p> <p class="MsoNormal"><font face="Courier New" size="2"><span style="mso-spacerun: yes"> </span><font color="#008000">‘ …</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">Dim</font> strUrl <font color="#0000FF">As String</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">Dim</font> strFormData <font color="#0000FF">As String</font><span style="mso-spacerun: yes"><br> <br> </span><font color="#008000">‘ Suppose that the version of our app is “A”</font><span style="mso-spacerun: yes"><font color="#008000"> </font> <br> </span>strFormData = "<b>Version=A&Key=123ABC</b>"<span style="mso-spacerun: yes"><br> </span>strUrl = "The address of the prev.. ASP page"</font></p> <p class="MsoNormal"><font face="Courier New" size="2"><span style="mso-spacerun: yes"> </span>Inet1.url = strUrl<span style="mso-spacerun: yes"><br> </span>Inet1.Execute strUrl, "POST", strFormData, _<span style="mso-spacerun: yes"><br> </span>"Content-Type: application/x-www-form-urlencoded"<span style="mso-spacerun: yes"><br> </span><font color="#008000">‘ …</font> <o:p> </o:p> </font></p> <p class="MsoNormal"><font face="Courier New" size="2"><font color="#0000FF">Private Sub </font>Inet1_StateChanged(<font color="#0000FF">ByVal</font> State <font color="#0000FF">As Integer</font>)<span style="mso-spacerun: yes"><br> </span><font color="#0000FF">Dim</font> strTemp <font color="#0000FF">As String</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">If</font> <b>State</b> = <b>12</b> <font color="#0000FF">Then</font> <font color="#008000">‘ If operation is completed</font><span style="mso-spacerun: yes"><br> </span>strTemp = <b>Inet1.GetChunk</b>(32000)<span style="mso-spacerun: yes"><br> </span>strTemp = Trim(strTemp)<span style="mso-spacerun: yes"><br> </span><font color="#0000FF">If</font> strTemp = “to_app” <font color="#0000FF">then</font><span style="mso-spacerun: yes"><br> </span>MsgBox “You must update the application!”<span style="mso-spacerun: yes"><br> </span><font color="#0000FF">ElseIf</font> strTemp = “ok” <font color="#0000FF">then</font><span style="mso-spacerun: yes"><br> </span>MsgBox “No updates aviable”<span style="mso-spacerun: yes"><br> </span><font color="#0000FF">Else</font><span style="mso-spacerun: yes"><br> </span>MsgBox “Unknow response”<span style="mso-spacerun: yes"><br> </span><font color="#0000FF">End If</font><span style="mso-spacerun: yes"><br> </span><font color="#0000FF">End If</font><br> <font color="#0000FF">End Sub</font></font><br> <br> <font face="Tahoma" size="2">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.<br> Remember that you must URL-Encode each byte you send to the page and that some special chars may <b>lost</b> during encoding.<br> <br> That’s all, folks<br> <br> Hope this tutorial help you!<br> SebaMix</font></p>
Original Comments (3)
Recovered from Wayback Machine