Table Builder...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary L. Olivieri

    #1

    Table Builder...

    I am trying to create a set of functions so that I can dynamically and
    programmaticall y create a table.

    The table will be a calendar when it is displayed on the screen and has 5
    types of cells.. Month header, Date, Info, Contents, and Filler.

    This is the code that I am using:

    Private Sub Page_Load(...

    Build Calendar()

    End Sub

    Private Sub BuildCalender()

    Table1.Rows.Add (BuildRow(1,Tod ay())

    End Sub

    Function BuildRow(byval type as integer, byval sDate as Date) as TableRow
    BuildRow.Cells. Add(BuildCell(1 ,1))
    End Function

    Function BuildCell(byval type as integer, byval contents as integer) as
    TableCell

    Select Case Type
    Case 1 ' Month
    BuildCell.Borde rStyle = BorderStyle.Rid ge
    BuildCell.BackC olor = BuildCell.Borde rColor
    BuildCell.Text = "Test Month Text"
    BuildCell.Heigh t.Pixel(24)
    BuildCell.RowSp an = 14
    End Select
    End Function


    When I try to run this I get an error "Object reference not set to an
    instance of an object." on line 41 which is
    BuildRow.Cells. Add(BuildCell(1 ,1))

    Any help with this would be great!

    Thanks in advance,

    GaryO

  • Phill.  W

    #2
    Re: Table Builder...

    "Gary L. Olivieri" <GaryO@bridgeca pitalusvi.com> wrote in message
    news:BF4DAD41.1 DC0%GaryO@bridg ecapitalusvi.co m...
    .. . .[color=blue]
    > Function BuildRow(byval type as integer, byval sDate as Date) as TableRow
    > BuildRow.Cells. Add(BuildCell(1 ,1))
    > End Function[/color]

    Within the BuildRow Function, you get a "free" variable, with the
    same name as the function to use as its return value. But, in this case,
    that return value is still an Object and you have to instantiate it before
    you can call methods on it, something like

    Function BuildRow( _
    byval type as integer _
    , byval sDate as Date _
    ) as TableRow
    ' Not sure what you do with "type" (dodgy name) and sDate, but

    BuildRow = New TableRow()

    BuildRow.Cells. Add(BuildCell(1 ,1))

    Return BuildRow
    End Function

    HTH,
    Phill W.


    Comment

    Working...