How to create arrays of textbox etc...

vlnarayanan

New member
Joined
Jun 11, 2007
Messages
3
Programming Experience
Beginner
Hi all,
I just wanna know..How to create control arrays..
In vb it was like textbox.text and label.text....

Could any one help me to solve this in vb.net

Thanks in advance


Regards
Lakks
 
Im interrested in that aswell.
Someone please give a nice explanation on how to ^^

Never even thought about it beeing possible..
Only know how to refer to textboxes when using I, but not as an array :eek:
 
You would normally use the containers Controls collection, but you can also declare your own collections or arrays of different types.
VB.NET:
    Private TextboxArray(5) As TextBox

    Private Sub tba()
        For i As Integer = 0 To 4
            Dim tb As New TextBox
            tb.Location = New Point(10, i * tb.Height)
            TextboxArray(i) = tb
        Next
        Me.Controls.AddRange(TextboxArray)
    End Sub
 
what do you need a textbox array for? Whats it used for. I just dont see why you have to use it, in difference with the regular arrays.. Im rather new at vb.net so i'd like to learn as much as possible ^^ Don't mind me asking please :eek:
 
I don't know if this is a good way to simulate control arrays ( in an easy way ). But I use the following code to simulate them if it has to go quickly.

VB.NET:
    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim txtBoxes(3) As Control
        txtBoxes(0) = txtName
        txtBoxes(1) = txtAddress
        txtBoxes(2) = txtEmail
        txtBoxes(3) = txtComment
    End Sub
 
Back
Top