DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2006
    Posts
    1

    Looping through text boxes on a form

    I have a form with 10 text boxes, names Server1 through Server10

    I would like to do something like:

    for loop = 1 to 10
    if ("server" & loop).TEXT = "something" do something
    next

    I cannot get this to work. I'm using VBA on a form in Word2003.

    Any help is appreciated.

  2. #2
    Join Date
    Feb 2004
    Location
    Colton, CA
    Posts
    550
    create the text boxes in an array (set the name to the same, but use the index property).

    So

    Code:
    for i = 0 to 9
        if server(i).text = "something"
        then
            server(i).text = "something else"
        end if
    next i

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Rich: Does Word VBA support control arrays?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    VBA does not support control arrays.

    Here is a good workaround:

    http://www.tek-tips.com/faqs.cfm?fid=4085

Similar Threads

  1. Creating Scrollable Text Boxes
    By Miles Tones in forum VB Classic
    Replies: 4
    Last Post: 05-26-2005, 09:38 AM
  2. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 06:53 AM
  3. Double Text 1.0
    By George Gilbert in forum vb.announcements
    Replies: 0
    Last Post: 08-19-2001, 11:34 AM
  4. TD font assignment, text boxes, & NN4
    By JPisan in forum Architecture and Design
    Replies: 1
    Last Post: 12-21-2000, 04:49 AM
  5. Rich Text Boxes
    By Jerry O'Connor in forum authorevents.vaughn
    Replies: 1
    Last Post: 06-01-2000, 06:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links