Holey_yan

20141115_VisualBasic_ControlArray

Nov 15th, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.78 KB | None | 0 0
  1. '20141115 Control Array Example
  2. 'Maker  : Yan
  3. 'Date   : 2014/11/15 pm.11:00
  4.  
  5. 'Form 表單內含
  6. ''Textbox * 6 (Textbox1 ~ Textbox6)
  7. ''Button  * 1 (Button1)
  8.  
  9. '本範例是採控制項陣列(Contral Array)
  10. '利用控制項陣列,以迴圈控制Textbox.Text 的值
  11.  
  12. Public Class Form1
  13.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  14.         Dim textbox_array() As TextBox = New TextBox() {TextBox1, TextBox2, _
  15.                                                         TextBox3, TextBox4, _
  16.                                                         TextBox5, TextBox6}
  17.         For i As Integer = 0 To textbox_array.Length - 1 Step 1
  18.             textbox_array(i).Text = i.ToString
  19.         Next
  20.     End Sub
  21. End Class
Advertisement
Add Comment
Please, Sign In to add comment