Re: Controls Problem

From: Valter Minute (vminute_at_REMOVEMEinwind.it)
Date: 06/29/04

  • Next message: Yu: "Portrait and Landscape in .Net 4.2 ?"
    Date: Tue, 29 Jun 2004 00:50:31 -0700
    
    

    "Gigaworld" <servizi@gigaworld.it> wrote in news:g8ZDc.390213
    $hc5.16844542@news3.tin.it:

    > I have this PROBLEM with controls collection:
    >
    > The old VB 6.0 syntax was:
    >
    > MyStr = me.controls("button1").text
    >
    > VB .NET doesn't function in this way, because in .NET
    > I must know the index of the control! I need to use the
    > STRING NAME of the control to address the object, because
    > my target is doing something like this:
    >
    >
    > for i = 1 to 10
    > MyStr(i) = me.controls("button" & i ).text
    > next i
    >

    You could implement a function that enumerates the controls and return
    the one that has the name property matching the one you're looking for.

    I don't know if it's granted that the controls are indexed in the same
    order you added them to the form.
    If it's granted, you may change your code in this way:

    for i = 1 to 10
          MyStr(i) = me.controls(IndexOf(firstbutton)+1).text
    next i

    Provided that you added the controls in the right order, of course.

    P.S. this kind of VB-related questions should be posted in vb.net,
    compact-framework or application programming newsgroups where you'll
    find more people that could help you.

    -- 
    Valter Minute
    vminute@inwind.it (the reply address of this message is invalid)
    

  • Next message: Yu: "Portrait and Landscape in .Net 4.2 ?"