Hello everybody,
I'm creating a control array which I need to make on certain moment visible or not.
Right now the only controls in my ctl array are labels. If I want to make them visible, I want to use in my ShowInvoice sub a loop to loop through my control array.
Everything works fine ... only if I useVB Code:
typeof sInvoice(i) is label then sInvoice(i).visible=true end if
If I just use sInvoice(i).visible = true (without the typeof condition) then I receive Object reference not set to an instance of an object
I don't want to change my showinvoice routine each time when there's a new kind of control in my array !
I really don't see why this is happening !
Hope someone can help me out !
This is my code (this doesn't work => but I want this one to work)
VB Code:
Private Function InvoiceArray() Dim sInvoice(20) As Control sInvoice(1) = lblInvoiceTo sInvoice(2) = lblInvoiceName sInvoice(3) = lblInvoiceAddress sInvoice(4) = lblInvoiceNr sInvoice(5) = lblInvoiceZip sInvoice(6) = lblInvoicePlace Return sInvoice End Function Private Sub ShowInvoice() Dim sInvoice() As Control Dim i As Integer sInvoice = InvoiceArray() Dim ctl As Control For i = 0 To UBound(sInvoice) sInvoice(i).Visible = True Next
This doesn't work
VB Code:
For i = 0 To UBound(sInvoice) sInvoice(i).Visible = True If TypeOf sInvoice(i) Is Label Then sInvoice(i).Visible = True Response.Write(sInvoice(i).GetType.ToString) End If Next





Reply With Quote