在vb.net中分配值Textbox数组的问题 [英] issue with assigning value Textbox array in vb.net

查看:154
本文介绍了在vb.net中分配值Textbox数组的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在表单加载事件中创建文本框数组



表单加载事件

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



按钮点击事件为这些文本框分配新文本。

但我得到错误对象参考(basiccaly itot canot找到那个文本框)如何解决这个问题


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

推荐答案

如果你在Form_Load事件中声明数组,那么它是一个过程级变量,所以一旦Form_Load结束,数组就消失了。将你的Dim语句移出Form_Load到类级别。
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.


这篇关于在vb.net中分配值Textbox数组的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆