
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 展开
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 展开
1个回答
展开全部
打击。自己搞了下。才知道原来是这个意思!
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询