Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am able to create textbox array in form load event

form load event
dim mytextbox() as new textbox
dim i as integer
for i 1 to 10
      mytextbox(i) as new textbox
      controls.add(mytextbox(i)
      mytextbox(i).text  = i + 1
next

on button click event assign new text to those text boxes.
but i get error object reference (basiccaly it canot find that text box) how do I solve this issue
Posted
Updated 2-Aug-13 6:20am
v2
Comments
CHill60 2-Aug-13 13:46pm    
Well the code you have posted here won't even compile. If woopsydoozy's solution still doesn't work for you then also post the code behind your button that is assigning the text to the text boxes

1 solution

If you're declaring the array inside your Form_Load event, it's a procedure-level variable, and so as soon as the Form_Load ends, the array is gone. Move your Dim statement outside the Form_Load to the class level.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900