Overview:
The Professional and Enterprise Editions of Visual Basic are shipped with the Winsock control. This control allows you to use the low level Windows Sockets to connect to remote servers and execute commands or download Web pages. This tip shows how to connect to a server and download a Web page.
You must have a Winsock control loaded into the project. This code assumes the control is called Winsock1. There also must be a text box on the form which is called txtWebPage.
Code:
First, connect to the remote computer using the following code:
Winsock1.RemoteHost = "microsoft.com"
Winsock1.RemotePort = 80
Winsock1.Connect
In the Winsock1.Connect event, place the following code to download the web page.
Dim strCommand as String
Dim strWebPage as String
strWebPage = "http://www.microsoft.com/index.shtml"
strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + vbCrLf
Winsock1.SendData strCommand
The Winsock control will attempt to download the page. When is receives some data from the server, it will trigger the DataArrival event.
Dim webData As String
Winsock1.GetData webData, vbString
TxtWebPage.Text = TxtWebPage.Text + webData
'end code
'coding by Phillip N
Previous Post
How to create app manifest for VB in winXP
How to create app manifest for VB in winXP
Related Posts
Source 1.0, .COM-file dissasemblerDissasemberMake Source 1.0, .COM-file dissasemblerTo generate assembly language source fi
Databases and Sql as a Middle Tier Storage MediumDOTNUTSHELL Technologies are an experienced database designing company , with Oracle ac
Complete Code ProtectorCode Security is a great VB Tools from G-soft, Code Security is a very small program but
Read Registry values in VB without APIOften you'll want to manipulate the Windows registry in VisualBasic without resorting to
CodeBank v2 Personal DataCodeBank v2 is tree based (XML) personal information database. It allows you to maintain
Control Two Computers with a Single Keyboard and MouseMouse Without Borders. If you’re only linking PC’s, Mouse without Borders’ really easy s