Visual Basic CGI Programming
Here are some examples of programming for the Common Gateway Interface (CGI) in Visual Basic 5.0, to demonstrate how simple Visual Basic CGI programming is.
The examples increase in complexity, demonstrating different aspects of CGI programming in Visual Basic. After reading this page, you should know everything you need to in order to create useful CGI programs, with your imagination the only limit.
All the CGI examples on this page use the CGI4VB.BAS module, written by Kevin O'Brien. They have been tested using Windows NT 4.0 Internet Information Server and Windows 95 Personal Web Server, but should work using any Windows 32-bit server. To view the source code, you will need Visual Basic 5.0 or higher (or notepad)! The examples assume you already have a basic knowledge of the Common Gateway Interface.
This simple example demonstrates how a Visual Basic program can be used as a web page, without any input from the user. It would be almost useless on its own, but it demonstrates some of the procedures used in creating CGI programs in Visual Basic.
This example shows how user input can be taken from a web-based form and turned into a Visual Basic variable, and how common Visual Basic functions can be integrated in the output.
This combines the previous examples, resulting in a useful CGI application. The guestbook uses two programs, one for signing the guestbook and one for viewing the contents of the guestbook.
To sign the guestbook, a CGI program takes values from a form and appends them to the end of a text file.
To view the guestbook, a separate program reads these values from the file and formats them in a HTML page.
The guestbook is very simple and quite effective. I have not tested it when two users on different machines submit entries at the same time but I suspect it would need further work to make this possible.
To test the program, compile the two programs in .EXE files and move these files into the scripts directory of your web server. The view program can be executed directly, and the sign program needs a form. See the .ZIP files for further information.
Please feel free to include any of the code on this page in your Visual Basic programs. If possible, please indicate that the original code was obtained from this page somewhere in your program or include a link on your web page if the program is a CGI script. Thanks!
source: http://www.users.dircon.co.uk/~tbrown/vb/cgi.htm#Hello
|