Subroutine RW - Response Write - February 2011

If you download this tip please consider making a modest donation.

Some years ago I wrote a very simple subroutine called 'RW'. The subroutine issues a Response.Write. I use it extensively while testing web applications. It is more useful than using Debug.Print, or any other method I've found, to send test results to the page.

Demo Web Application

I wrote a simple Asp.Net, VB.Net, VS/2008 web application to demonstrate the routine.

Text Box - Enter any text in the text box then click the button. The text is shown at the beginning of the page using the Response.Write method.

The Entire RW Subroutine

Public Sub RW(ByVal sResponse As String, _
        Optional ByVal iNumberOfBRs As Integer = 1, _
        Optional ByVal bForce As Boolean = False)
    Dim bDoit As Boolean = bForce
    If IsAuthor() = 2 Then
        bDoit =
bDoit Then
sBR As String = ""
        For i As Integer = 1 To iNumberOfBRs
            sBR &=
"<br />"
        HttpContext.Current.Response.Write(sResponse & sBR)
    End If

    Catch ex As Exception
    End Try

The RW Format and Operands

Include modResponseWrite.vb in your application. The RW subroutine:

Code Description Sample
RW(sResponse[,iNumberOfBRs][,bForce] The Response.Write subroutine.  
  sResponse The text to be displayed. "Some Text"
  iNumberOfBRs The number of carriage returns to be used, default is one 4
  bForce If IsAuthor then perform the operation. But the operation
can be forced by setting this value to True
IsAuthor See: IsAuthor - October 1998 - August 2006  
TraceWrite See: TraceOpen and TraceWrite - May 2002  

Caveat Emptor

Don't use too many RW [Response.Write] statements together. I recently used 24 in a row to give as hour by hour response. It takes some time for each to execute. It is quicker to build an output string then issue only one RW.

Download the VB.Net Code

Download the source code by clicking on the zipped file name.

Download - Source Zipped File Size
VS/2008 VB.Net, ASP.Net Solution 24K

Previous Tip    Tip Index    Next Tip


Updated 2011/04/16