home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1998 September / Sezamfile98_2.iso / VBasic / VB5-CGI.ZIP / demoHTML.ba_ / demoHTML.ba
Text File  |  1998-06-08  |  4KB  |  60 lines

  1. Attribute VB_Name = "modHTML"
  2. 'VB5-CGI Objects script example: demoHTML.bas
  3. 'Copyright 1997, 1998 EazyWare - http://www.eazyware.com/vb5-cgi
  4. '---------------------------------------------------------------
  5. 'Shows the basic functionalities of the VB5HTML object.
  6. '---------------------------------------------------------------
  7.  
  8. Option Explicit
  9. Private CGI  As New VB5CGI.clsCGI       'Instance the VB5CGI Object (needs VB5CGI.DLL)
  10. Private HTML As New VB5HTML.clsHTML     'Instance the VB5HTML Object (needs VB5HTML.DLL)
  11.  
  12. Sub Main()
  13.     With HTML
  14.         'Add an additional text (e.g. your e-mail address) to an occuring error message
  15.         .ErrorSubText = "Please, send your comments to " & .GetTextLink("EasyWare", "mailto:tools@eazyware.com")
  16.         .BodyFileHeader = "\demoHEAD.htm"                           'Use a HTML header file
  17.         .BodyFileFooter = "\demoFOOT.htm"                           'Use a HTML footer file
  18.         'Retrieve and check the query string (allow only POST-method and max 1024 not encoded characters)
  19.         If .InitQueryString(True, 1024) Then
  20.             'Validate the FirstName entry. Allow only US letters, Spaces, min 3 to max 25 characters
  21.             If Not .HasKeyValidStringContent("FirstName", htmlLetterUS + htmlSpace, 3, 25) Then
  22.                 'If the entry was not valid, submit a simple information page
  23.                 .SubmitPage "Validation", "Please enter your first name (US letters, Spaces, min 3 to max 25 characters)", True
  24.                 End                                                 'And end the script
  25.             End If
  26.             If Not .HasKeyValidStringLen("LastName", 2, 25) Then    'Validate the LastName entry
  27.                 .SubmitPage "Validation", "Please enter your last name (2 to 25 characters)", True
  28.                 End
  29.             End If
  30.             If Not .HasKeyValidIntegerRange("Age", 1, 150) Then     'Validate the Age entry
  31.                 .SubmitPage "Validation", "Please enter your age (1 to 150 years)", True
  32.                 End
  33.             End If
  34.             'Start the sample page with a title and background color
  35.             .PageBegin "VB5-CGI Objects demonstration [" & CGI.GetScriptName(True) & "]", "#FFFFCC"
  36.             .HeadMetaNameContent "Author", "James Bond"             'Add a meta tag
  37.             .BodyTag "H2", "Dear " & .GetKeyString("FirstName") & " " & _
  38.                            .GetKeyString("LastName") & ", welcome to the VB5HTML demo!"
  39.             .BodyTextBI "Some demo information:"
  40.             .BodyListBegin True, "A"                                'Begin a new ordered list
  41.             .BodyList "First Name: " & .GetKeyString("FirstName")   'List the FirstName
  42.             .BodyList "Last Name: " & .GetKeyString("LastName")     'List the LastName
  43.             .BodyList "Age: " & .GetKeyInteger("Age")               'List the Age (as integer)
  44.             .BodyList "Default Path: " & .DefaultPath()             'List the default path
  45.             .BodyList "Script Filename: " & CGI.GetScriptName()     'List the script name
  46.             .BodyList "Browser: " & CGI.EnvHTTPUserAgent            'List the browser type (from environment variable)
  47.             .BodyListEnd                                            'End the list
  48.             .BodyHRule True, 2, "20%", htmlAlignCenter
  49.             'Show and increment the hit counter, but only for this page
  50.             .BodyTextFont "This page has been accessed " & CGI.GetHitCounterInc(App.EXEName) & _
  51.                           " times!", 1, "#0000FF", "Arial, Helvetica", True
  52.             .BodyBreak
  53.             .PageEnd                                                'End and submit the complete page
  54.         Else
  55.             'Occures, if other than a POST-method was used, or no query string was submitted
  56.             .ErrorPage "No POST method used, or no Query String received!"
  57.         End If
  58.     End With
  59. End Sub
  60.