HelloWorld -- The First Program

We use a very small VB program HelloWorld as the start point for the tour to introduce web programming in Visual Basic with WebRainbow. Hello World is a famous program for C/C++ programmer as first program they wrote. Here we just implement it in Visual Basic, utilizing WebRainbow. The program will display Hello World! in the browser.

  1. Start Visual Basic

  2. Select Standard EXE as project type

  3. Select Sub Main as Startup Object

  4. Give HelloWorld as project name

  5. Set reference to WRHttpB.tlb, WRMimeB.tlb, and WRnbwB.tlb

  6. Remove Form1, the default form for new VB project

  7. Add one standard module into the Project, name it modHelloWorld

  8. In the module modHelloWorld, type in the following code:
        Option Explicit
    
        Sub Main()
    
          CPrint "<HTML>"
          CPrint "<BODY>"
          CPrint "<CENTER>"
          CPrint "<FONT SIZE=""5"" COLOR=""RED""><EM><B>"
          CPrint "<P>Hello World!"
          CPrint "</B></EM></FONT>"
          CPrint "</BODY>"
          CPrint "</HTML>"
    
        End Sub
      

  9. Compile this small program to HelloWorld.exe.

  10. Click on Debug in VB IDE for detailed debug instruction.

  11. Click following link to

What did you see? It is Hello World!

There is Hello World! shown in your browser in red color! This is a real web application! it's so simple! But it is true! This is the power of WebRainbow. All the underneath job to make web application simple is handled by WebRainbow.

This small Web program only calls to one function CPrint several times. It is the exposed function of WebRainbow.DynaPage, and used to send HTML content to browser

The only point we need to pay attention is the double quote. Let us take look at this line:

CPrint "<FONT SIZE=""5 "" COLOR=""RED ""><EM><B>"

There are 2 double quotes before and after digit 5 as well as word RED. This is the way for Visual Basic to put a double quote " into the string.


For the latest information on WebRainbow, please see:
http://www.dmfsys.com/wrainbow/

For questions / comments please email to:
support@dmfsys.com


Copyright © 2000 -2005 D.M.F. Systems, Corporation. All rights reserved.

Last modified on March 2, 2005