newman     VBWeb     VBSource     Portfolio    
OUT ON THE INTERNET


Home

Getting Started
- Hello World Example
- SampleMain Example
- Code Snippets
- Request Collection
- Missing Terms
- Multi-Select
- Names Collection

User Guide
- Debugging
- Stepping Through Code
- HTML Templates
- Cookies

Command Reference
- AddToRequest
- BackupRequest
- CgiDebugPrint
- ErrorHandler
- Escape
- Extract
- FileContents
- FileExists
- GetRequest
- GmtDate
- IsVBIDE
- LoadRequest
- Parse
- Redirect
- Replace
- Send
- SendLn
- ServerVariables
- SetCookie
- StandardIn
- UrlDecode
- UrlEncode

Appendix
- Web Server Directory Mapping
- Computer Name & IP Address

Reference

Redirect

Sends the visitor to another web page instead of generating a page.
Syntax
Redirect Url
Call Redirect(Url)
Url - Required text that is the URL of another web page. This text looks like the address you enter in the Location text box of a browser.

Remarks
Nothing should be sent to the visitor before or after calling this command. No other headers need to be sent, not even "Content-Type: text/html".

Example
This example is a Main procedure so you can see that nothing else gets sent. Visitors that enter invalid report names get redirected back to the home page. Public Sub Main() On Error GoTo Trap Rpt = GetRequest("ReportName") If IsValidReportName(Rpt) Then SendLn CGI_CONTENT_TYPE_TEXT_HTML Call GenerateReport(Rpt) Else 'No report requested, so go home. Call Redirect("/index.htm") End If End Trap: Call ErrorHandler End Sub

Replace

Returns TextIn with each occurrence of Placeholder replaced with Replacement.
Syntax
TextOut = Replace(TextIn, Placeholder, Replacement)
Part
Description
TextIn Required text with embedded Placeholders.
Placeholder Required text to be found in TextIn.
Replacement Required text that replaces each Placeholder in TextIn.

Remarks
This function is intended for use with HTML Templates. But it is general enough to be used for many other functions. Examples of using this function with HTML templates are in the User Guide.

Note: This function is called by UrlDecode and UrlEncode in the VbWeb.Bas module.

Examples
If you put text in the Caption property of a Label control, one Ampersand (&) shows up as a Hot-Key. And two Ampersands (&&) show up as one (&). Therefore, to make one Ampersand show up as one, replace them with two. Label1.Caption = Replace(Text1, "&", "&&") To make text out of a label caption, reverse the process. There's a trick to this. This example uses %and% as a temporary placeholder. Function GetCaption(TextIn) Work = Replace(TextIn, "&&", "%and%") Work = Replace(Work, "&", "") GetCaption = Replace(Work, "%and%", "&") End Function For Microsoft Access databases, the text in Text fields have three special characters: Single-Quote ('); Double-Quote ("), and Pipe (|). This example fixes them. Function FixAccess(TextIn) Work = Replace(TextIn, "'", "''") Work = Replace(Work, """", """""") FixAccess = Replace(Work, "|", "|Chr$(124)|") End Function


Copyright 1997 NEWMAN Services Corp. All rights reserved.
973-228-5753 pres@newmanservices.com