Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB help acces controls with a varible in a loop

Options
  • 30-03-2006 2:55pm
    #1
    Registered Users Posts: 221 ✭✭


    Ok what i want to do is go throught a for loop and add hte value ot a text box called textcnt where cnt is a for loop control to array(cnt) hope i explained that ok but can i do it ??


    I'm using vb 6 by the way


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Elfman wrote:
    but can i do it ??

    Yes, in that it is doable.

    I'd suggest you start by looking at the Controls collection of the Form object - it should allow you to reference controls as myForm.Controls[controlName] where controlName is a string value.

    From there, it should be simple.

    jc


  • Closed Accounts Posts: 51 ✭✭david powell


    if you want to cycle through the controls on a form, something like this might work:-

    Dim ctrl As Control

    For Each ctrl In Form1.Controls
    If TypeName(ctrl) = "TextBox" Then
    With ctrl
    .Text= "hi"
    End With
    End If
    Next ctrl


  • Registered Users Posts: 221 ✭✭Elfman


    Ah wow guys excellent ideas coo will try try them v soon and get back to ye thanks a millioin


    -Elfman


Advertisement