vb.net应用程序的数组问题

TextBox1.ReadOnly=TrueTextBox2.ReadOnly=TrueTextBox3.ReadOnly=TrueTextBox4.ReadOnly=T... TextBox1.ReadOnly = True
TextBox2.ReadOnly = True
TextBox3.ReadOnly = True
TextBox4.ReadOnly = True
TextBox5.ReadOnly = True
TextBox6.ReadOnly = True
TextBox7.ReadOnly = True
TextBox8.ReadOnly = True
TextBox9.ReadOnly = True
TextBox10.ReadOnly = True
TextBox11.ReadOnly = True
TextBox12.ReadOnly = True
TextBox13.ReadOnly = True

请问有没有循环语句实现以上功能啊 比如(伪代码):

dim i as integer
for i=1 to 13
textbox(i).ReadOnly=true
next
展开
 我来答
热一点很搞笑
2008-09-09 · TA获得超过337个赞
知道小有建树答主
回答量:478
采纳率:0%
帮助的人:248万
展开全部
打击。自己搞了下。才知道原来是这个意思!

Controls("Text" & i).Text = i

这么搞就行了!呼呼。。
/////////////////////

Dim i%, t As TextBox
For i = 1 To 5
Set t = CallByName(Me, "Text" & CStr(i), VbGet)
t.Text = CStr(i)
Next
这是用callbyname函数做的例子...不过比你的看起来差...
不过这个方法也适用于全局变量...比如说...
Option Explicit

Public a1%, a2%, a3%
Private Sub Command1_Click()
Dim i%
For i = 1 To 3
'Debug.Print CallByName(Me, "a" & CStr(i), VbGet)
CallByName Me, "a" & CStr(i), VbLet, i
Next
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式