contents   index   previous   next



Project Setup

 

After starting Visual BasicVisual Basic, as shown in Figure 2.1.1, choose a Standard EXE as the project type you would like to create. From Project/Components add WebX as shown in Figure 2.1.2.

 

Figure 2.1.1 – Start Project Figure 2.1.2 – Add Component

 

 

The control has been added to the components toolbar in the IDE, as shown in Figure 2.1.3. 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 in Figure 2.1.4.

 

 

 

 

 

Figure 2.1.3 – WebX Icon on Components Toolbar. Figure 2.1.4 – 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 .ServerRunningProperties:ServerRunning = False Then

 

.ServerPortProperties:ServerPort = 8888

 

.VirtualPathProperties:VirtualPath = App.Path & "\html"

 

.StartServerMethods:StartServer

 

Caption = "Server Running."

 

Command1.Caption = "Stop Server"

 

Else

 

.StopServerMethods:StopServer

 

Caption = "Server Stopped."

 

Command1.Caption = "Start Server"

 

End If

 

End With

 

End Sub

Figure 2.1.5 – 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.

 


Project Notes