我現在要寫一個程式
功能是新增動態控制項 textbox 十個 預設為0
點下去之後值會設成1
//=========
以下是我的程式,不知道哪邊有問題
//==========
Public Class Form1
Dim txta(10) As TextBox
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim i As Short
For i = 0 To 10
txta(i) = New TextBox
txta(i).Left = 30 + 20 * i '設定位置
txta(i).Top = 10
txta(i).Height = 20 '大小
txta(i).Width = 20
txta(i).Text = 0
txta(i).Cursor = Cursors.Default
txta(i).ReadOnly = True
txta(i).Visible = True
Me.Controls.Add(txta(i))
AddHandler txta(i).Click, AddressOf On_Click
Next
End Sub
Private Sub On_Click(sender As Object, e As EventArgs) Handles Me.Click
txta(i).Text = 1
End Sub
End Class
2014-05-27 23:22:00 補充
OK~ 我想多問一個問題
如果我宣告一個新的陣列
Dim Arytext(10) as short
然後我想在被點到的textbox相對應的陣列中設值為1,Arytext(i)=1
ex:我點txta(2),txta(2).text會等於1,同時Arytext(2)=1
這樣該如取得 i 值,該怎麼寫?謝謝^_^
2014-05-28 11:21:36 補充
大概知道了
那如果變成是二微陣列呢?
因為tag屬性好像只有一個
例如一開始變成宣告
dim txta(10,10) , Arytext(10,10) as textbox
那要怎麼對應txta(i,j)與Arytext(i,j)
sorry問題有點多QQ
2014-05-28 11:29:07 補充
上面錯了 更正
dim txta(10,10) as textbox
dim Arytext(10,10) as short
2014-05-28 21:17:48 補充
終結者
謝謝你回答我這麼多問題
如果可以的話 可以補充一下其他的方法嗎?
Recommended article: Chomsky: We Are All – Fill in the Blank.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.