Results 1 to 3 of 3

Thread: looping with variable control name

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    looping with variable control name

    I have this code:
    VB Code:
    1. For i = 1 To 4
    2.     For j = 0 To 4
    3.         SQLSTR = "INSERT INTO Coeff (CAL_ID, Curve_Order, Coeff, Coeff_Val) VALUES (" & CALID & ", " & i & ", " & j & ", " & frmRegression.txtCoefficient_ & i & (j) & ")"
    4.         CN.Execute (SQLSTR)
    5.     Next j
    6. Next i

    And what I'm trying to do is loop through sets of control arrays to store some variables. It's the following line that I have a problem with:

    frmRegression.txtCoefficient_ & i & (j)

    I need a way to make it look for that control array and then get that value from that control array. I know there has to be an easy way to do this.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: looping with variable control name

    What exactly is the name of your control array and their indexes?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: looping with variable control name

    You will need to use the Form's Controls collection.
    Try the following

    frmRegression.Controls("txtCoefficient_" & i)(j).Text

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width