SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Sep 2006
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Referencing a VB Form listview control dynamically

    Not sure if this is the right place to ask this, but here goes...
    I have a userform in testpartner where one of the pages has multiple listview items (named Item1_Per1, Item1_Con1, Item1_Per2, Item1_Con2, Item1_Per3, Item1_Con3, Item1_Per4, Item1_Con4).
    I am using an SQL query to take data out of a table and place into each listview in turn.
    Currently I am referencing each listview explicitly by name (eg, Me.Item1_Per1 etc).
    Is there anyway that instead of having the same code repeated for each listview (and manually specifying "Me.Item1_Per1" etc), that I could make use of a variable instead?

    something like:

    Dim Perlabel as string
    Dim Conlabel as string
    Dim i as integer
    for i = 1 to 4
    Perlabel="Item1_Per" & i
    ConLabel="Item1_Con" & i
    With Me.Perlabel
    <do some stuff here>
    end with
    with Me.Conlabel
    <do some more stuff here>
    end with
    next

    If so what do I need to specify Perlabel and Conlabel above as (as string doesn't work)?

    Just thought it would be neater than using four chunks of almost identical code to do the job.

    Any help would be gratefully received as I'm quite new to this...

  2. #2
    Member
    Join Date
    Jul 2003
    Location
    Germany
    Posts
    458
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Referencing a VB Form listview control dynamic

    you could e.g. use a function:

    <font class="small">Code:</font><hr /><pre>
    '$TPInclude "frmListBoxes"

    Sub fillListbox(mybox As ListBox)
    mybox.AddItem "xyz"
    End Sub

    Sub Main()

    fillListbox (frmListBoxes.ListBox1)
    fillListbox (frmListBoxes.ListBox2)

    End Sub
    </pre><hr />

  3. #3
    Member
    Join Date
    May 2004
    Location
    Chicago
    Posts
    379
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Referencing a VB Form listview control dynamic

    I was going to suggest a control array (Similar on VB6 forms). Doesn't seem to work on the User Forms. If someone knows how to do it that would be another way of doing it, but as I said don't know if it is possible.
    Richard DeMers
    QA Software Tester
    http://www.marchforbabies.org/rdemers25

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:37 AM.

Copyright BetaSoft Inc.