Table Builder...

  • Thread starter Thread starter Gary L. Olivieri
  • Start date Start date
G

Gary L. Olivieri

I am trying to create a set of functions so that I can dynamically and
programmatically 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,Today())

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.BorderStyle = BorderStyle.Ridge
BuildCell.BackColor = BuildCell.BorderColor
BuildCell.Text = "Test Month Text"
BuildCell.Height.Pixel(24)
BuildCell.RowSpan = 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
 
.. . .
Function BuildRow(byval type as integer, byval sDate as Date) as TableRow
BuildRow.Cells.Add(BuildCell(1,1))
End Function

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top