Project Setup
After starting Visual Basic, as shown below, choose a Standard EXE as the project type you would like to create. From Project/Components add WebX as shown below.
Start Project
Add Component
The control has been added to the components toolbar in the IDE, as shown below. Double click on the icon to add it to the Form. Double click on a command button to also add it to the Form as shown below.
WebX Icon on Components Toolbar
WebX Component on Form.
Now add the following code to the Form:
|
Option Explicit Private Sub Form_Load ' Set up the Form Command1.Caption = "Start Server" Caption = "Server Stopped." End Sub Private Sub Command1_Click With WebX1 ' Check the State of WebX and ' take appropriate action If .ServerRunning = False Then .ServerPort = 8888 .VirtualPath = App.Path & "\html" .StartServer Caption = "Server Running." Command1.Caption = "Stop Server" Else .StopServer Caption = "Server Stopped." Command1.Caption = "Start Server" End If End With End Sub |
Visual Basic Code for Simple Web Server.
Run the program. If there are any errors, check for any typing mistakes that may have occurred. Once the program is running, open your web browser and go to the following URL: http://localhost:8888. When you go to the above URL, you should see the welcome page for the Simple Web Server example project. If you do not see it or receive any errors, carefully double-check your typing.