Original Post
hi, im new to this forum so spare me :) hehe Im trying to create a button array in vb.net (if it is possible) .. im trying to generate 5 buttons automatically.. but its not initialising for me for some reason.. the code is quite simple.. Dim buttonarray(5) As Button For i = 0 To 4 buttonarray(i).Text = "Bleh" buttonarray(i).ID = i buttonarray(i).CommandName = "bleh" + i Controls.Add(buttonarray(i)) Next i Few questions: 1. Is this a valid code? The editor seems not to mind... not giving me any expression errors.. 2. Is button array possible? 3. Following error occures: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 36: Line 37: For i = 0 To 4 Line 38: buttonarray(i).Text = "Bleh" <---- at this particular line Line 39: buttonarray(i).ID = i Line 40: buttonarray(i).CommandName = "bleh" + i Thats about it.. if anyone else has any different suggestions.. i'd appreciate it. :) Cheers