07-30-2007, 04:00 PM
Hi Alll
Hope you can help

I have this code
NoOfFields = CInt(ds.Tables(gTableName).Columns.Count)
For gInt1 = 0 To NoOfFields - 1
Select Case gInt1
Case 0
TextBox0.DataBindings.Add("Text", ds.Tables!clients, ds.Tables(gTableName).Columns(gInt1).Caption)
Label0.Text = ds.Tables(gTableName).Columns(gInt1).Caption
Case 1
TextBox1.DataBindings.Add("Text", ds.Tables!clients, ds.Tables(gTableName).Columns(gInt1).Caption)
Label1.Text = ds.Tables(gTableName).Columns(gInt1).Caption
Case 2
TextBox2.DataBindings.Add("Text", ds.Tables!clients, ds.Tables(gTableName).Columns(gInt1).Caption)
Label2.Text = ds.Tables(gTableName).Columns(gInt1).Caption
End Select
Next gInt1

The only difference with the select case statement is the textbox(X)
In VB6 I could say
Str1 = "TextBox" & cstr(gint1)
then use

I could possibly have 12 textboxes


07-30-2007, 04:23 PM
is there a question in there?

07-30-2007, 04:54 PM
Are you looking for creating control arrays in .Net? If so, IcePlug created a nice tutorial a while back which might help you get started.

Also, I don't see why you need the select case at all, given you want the same number of controls as the "NoOfFields" variable. So you do a for loop exclusively, no need to evaluate what "gInt1" is, since you know what it is already via the standard for/next construct.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum