另一个阵列问题 [英] another array question
问题描述
我正在制作一个表格,您可以在其中添加带按钮的文本框。
要添加的最大文本框数为100
但是我还必须创建一个als文本框数组,
有没有办法创建一个尚未创建的文本框数组。
$ exapmle
Dim delayarray(100)As TextBox(100)< ---------------这不会工作
ofcourse
forti = 1 to 5
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56,inti * 10 + 64)
delayarray(inti).Visible = True
下一页
感谢Maarten
Dim mytextboxes As TextBox()
ReDim文本框(100)
for i as integer to 100
mytextboxes(i)= new textbox
mytextboxes(i).Text = i.tostring
next
" Maarten"写道:
我正在制作一个表格,您可以在其中添加带按钮的文本框。
要添加的最大文本框数量为100
>但我也必须创建一个als文本框数组,
是否有一种方法可以创建一个尚未创建的文本框数组。
fot exapmle
Dim delayarray(100)As TextBox(100)< ---------------这不会工作
inti = 1到5
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56,inti * 10 + 64)
delayarray(inti).Visible = True
感谢Maarten
Maarten,
Dim delayarray(100)As TextBox(100)< --------------- this不行不动
在这里你尝试创建一个包含101个文本框数组的数组(最后一个不会
甚至去)
什么时候你知道你想要多少个文本框而不是使用固定阵列
\\
Dim delayarray(99)As TextBox()
For inti = 0到99
delayarray(inti).name =" MyTextBox" &安培; inti.tostring
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56,inti * 10 + 64)
delayarray(inti).Visible = True
下一页
///
当你不知道有多少人时想要使用(奇怪的是这种
情况然而让我们假设,你可以使用arraylist)
\\\
dim delayarray as new arraylist
for inti = 0 to 99
directcast(delayarray,textbox).name =" MyTextBox" &安培; inti.tostring
dlayarray.add(delayarray)
Me.Controls.Add(delayarray(inti))
directcast(delayarray(inti) ,文本框).Location = New Point(56,inti * 10 + 64)
directcast(delayarray(inti),textbox).Visible = True
下一页>
///
在此消息中输入所有内容(已更改),以便查看拼写错误。
我希望这有帮助吗?
Cor
" Dennis" <德**** @ discussions.microsoft.com> schrieb:Dim mytextboxes As TextBox()
ReDim textboxes(100)
for i as integer to 100
mytextboxes(i)= new Textbox
mytextboxes(i).Text = i.tostring
next i
\\\
Const TextBoxesCount As Integer = 100
Dim TextBoxes(TextBoxesCount - 1)As TextBox
For i = 0 To TextBoxes.Length - 1
TextBoxes (i)=新TextBox()
...
下一页我是
Me.Controls.AddRange(TextBoxes)
///
;-)
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://dotnet.mvps.org/dotnet/faqs/ >
i''m making a form where you can add textboxes with a button.
the max number of textboxes to add is 100
but i also must create an array of al thes textboxes,
is there a way of creating an array of thextboxes that aren''t created yet.
fot exapmle
Dim delayarray(100) As TextBox(100) <--------------- this won''t work
ofcourse
For inti = 1 To 5
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56, inti *10 + 64)
delayarray(inti).Visible = True
Next
thanks Maarten
Dim mytextboxes As TextBox()
ReDim textboxes(100)
for i as integer to 100
mytextboxes(i) = new Textbox
mytextboxes(i).Text = i.tostring
next i
"Maarten" wrote:
i''m making a form where you can add textboxes with a button.
the max number of textboxes to add is 100
but i also must create an array of al thes textboxes,
is there a way of creating an array of thextboxes that aren''t created yet.
fot exapmle
Dim delayarray(100) As TextBox(100) <--------------- this won''t work
ofcourse
For inti = 1 To 5
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56, inti *10 + 64)
delayarray(inti).Visible = True
Next
thanks Maarten
Maarten,
Dim delayarray(100) As TextBox(100) <--------------- this won''t work
Here you try to create an array of 101 textbox arrays (where the last wont
even go)
When you know how many textboxes you want than use the fixed array
\\
Dim delayarray(99) As TextBox()
For inti = 0 To 99
delayarray(inti).name = "MyTextBox" & inti.tostring
Me.Controls.Add(delayarray(inti))
delayarray(inti).Location = New Point(56, inti *10 + 64)
delayarray(inti).Visible = True
Next
///
When you do not know how many you want to use (strange in this kind of
situations however let us suppose, you can use the arraylist)
\\\
dim delayarray as new arraylist
For inti = 0 To 99
directcast(delayarray,textbox).name = "MyTextBox" & inti.tostring
dlayarray.add(delayarray)
Me.Controls.Add(delayarray(inti))
directcast(delayarray(inti),textbox).Location = New Point(56, inti *10 + 64)
directcast(delayarray(inti),textbox).Visible = True
Next
///
All typed(changed) in this message so watch typos.
I hope this helps?
Cor
"Dennis" <De****@discussions.microsoft.com> schrieb:Dim mytextboxes As TextBox()
ReDim textboxes(100)
for i as integer to 100
mytextboxes(i) = new Textbox
mytextboxes(i).Text = i.tostring
next i
\\\
Const TextBoxesCount As Integer = 100
Dim TextBoxes(TextBoxesCount - 1) As TextBox
For i = 0 To TextBoxes.Length - 1
TextBoxes(i) = New TextBox()
...
Next i
Me.Controls.AddRange(TextBoxes)
///
;-)
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
这篇关于另一个阵列问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!