问题描述
我正在尝试在VB2005中创建一个控件数组.就像我在其他问题中所说的那样,我已经在VB5中工作了一段时间,但是我是VB2005的新手.我知道如何在VB5中设置数组,但在VB2005中不起作用.我尝试了一些别人告诉我的代码 关于,但是它不起作用.我有几本关于VB2005编程的书,但是对他们没有多大帮助
I'm trying to create a control array in VB2005. As I've said in other questions, I've been working in VB5 for a good while but I'm new to VB2005. I know how to set the array up in VB5 but it doesn't work in VB2005. I tried some code that someone told me about, but it's not working. I have several books on programming VB2005 but they're not much help
这是我现在的代码:
公共
类 frmMain
公共 lblFasting(30) As 标签
Public lblFasting(30)As Label
公共 lblLunch(30) As 标签
Public lblLunch(30)As Label
公共 lblSnack(30) As 标签
Public lblSnack(30)As Label
公共 lblDinner(30) As 标签
Public lblDinner(30)As Label
公共 lblDayOfMonth(30) As 标签
Public lblDayOfMonth(30)As Label
公共 CycleFast As 整数
Public CycleFastAsInteger
lblFasting(0)= lblFasting1
lblFasting(0) = lblFasting1
lblFasting(1)= lblFasting2
lblFasting(1) = lblFasting2
lblFasting(2)= lblFasting3
lblFasting(2) = lblFasting3
lblFasting(3)= lblFasting4
lblFasting(3) = lblFasting4
lblFasting(4)= lblFasting5
lblFasting(4) = lblFasting5
lblFasting(5)= lblFasting6
lblFasting(5) = lblFasting6
lblFasting(6)= lblFasting7
lblFasting(6) = lblFasting7
lblFasting(7)= lblFasting8
lblFasting(7) = lblFasting8
lblFasting(8)= lblFasting9
lblFasting(8) = lblFasting9
lblFasting(9)= lblFasting10
lblFasting(9) = lblFasting10
lblFasting(10)= lblFasting11
lblFasting(10) = lblFasting11
lblFasting(11)= lblFasting12
lblFasting(11) = lblFasting12
lblFasting(12)= lblFasting13
lblFasting(12) = lblFasting13
lblFasting(13)= lblFasting14
lblFasting(13) = lblFasting14
lblFasting(14)= lblFasting15
lblFasting(14) = lblFasting15
l
推荐答案
控制数组与vb5中的控制数组不同.在vb.net中,您可以声明标签数组+使用它来引用现有标签,但是如果在设计器中复制label1 +粘贴它,则不会使第一个标签label1(0)+粘贴 标记label1(1)在vb5中的方式.在vb.net中,粘贴的标签是label2,但是您可以使用数组来引用它们,即
control arrays in vb.net aren't the same as control arrays in vb5. in vb.net you can declare an array of labels + use it to refer to existing labels, but if you copy label1 in the designer + paste it, it doesn't make the first label label1(0) + the pasted label label1(1) the way it does in vb5. in vb.net the pasted label is label2, but you can use an array to refer to them, i.e.
将labels()视作label = {label1,label2}
dim labels() as label = {label1, label2}
这篇关于控制阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!