Processing HTML FORM

WebRainbow provides 3 functions to handle HTML FORM:
(click on link to display detailed explanation)

  1. GetFormData
  2. CountFormData
  3. SetRequestMethod

and 4 functions to deal with Cookie:

  1. GetCookie
  2. CountCookie
  3. SetCookie
  4. GetCookieVersion

As well as 2 functions to process URL ("%XX") encoding/decoding, which can be used for special character in cookie or other place:

  1. Chr2Hex
  2. Hex2Chr

We'll demonstrate how to use these functions in the Visual Basic by a simple Visual Basic Web application which handles HTML FORM and Cookie:

This Web Application, HtmlForm, contains three pages:

It processes almost all of the FORM elements, so you will get enough information to handle FORM for the real application.

Let's step into the code for details.

To process cookie, you need to call GetCookie to retrieve cookie, and SetCookie to send cookie. Some time, the Chr2Hex and Hex2Chr are needed to deal with URL encoding/decoding for some special character(s) in the value of cookie. WebRainbow gives a special string constant, ceEncodeChar, containing some commonly used special characters for cookie: TAB, SPACE, Double Quote, Comma, Semicolon. Cookie is widely used for shopping cart, and session control.

To deal with multi-valued FORM element, such as CHECK element, the CountFormData can be used to find how many pairs of name/value associated with same specified name, and then call GetFormData with both sName and sID specified to retrieve proper FORM data.

Note: The source code for VB 4 and VB 5 / 6, is almost identical, except vbNullString is used for optional argument in VB 4 code. This is due to the 32-bit version of VB 4, which we used to test WebRainbow, does not really support optional argument for exposed function of WebRainbow.

To try this demo, follow the steps list bellow:

  1. Start Visual Basic

  2. Select Standard EXE as project type

  3. Select Sub Main as Startup Object

  4. Give HtmlForm as project name

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

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

  7. Add HtmlForm.bas (source code for Visual Basic 5 & 6) or HtmlForm4.bas (source code for Visual Basic 4 32-bit), corresponding to the version of Visual Basic you used, into the Project HtmlForm. These two files are normally in the folder C:\Program Files\WebRainbow\demo\htmlform\ if you did not change the installation directory for WebRainbow.

  8. Compile it to HtmlForm.exe.

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

  10. Click following link to

Good luck!


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