Loop through text box array

Posted on 2006-05-12
Last Modified: 2010-05-01
I need to grab the values from several text boxes on several tabs (sstab).
I 'have' to grab them in order, at least a certain order...
They're laid out as such:

A  B
A  B
A  B

on each tab.

I'm writing these values to the registry, so A's value is going to be B, so I don't think a for/each would work here...
I 'thought' about adding a Tag to each "A" and/or each "B", but I'm wondering if there's a more effecient way.

For X = 0 To sstMain.Tabs - 1
   'Saves the Tab's caption as the section, then I need to save each txtData(y) with a value of txtData(y+1) (these are created in sequence,
   'starting at array 2, so all 'even' txtboxes would be the Key, and all odd's (above 1), would be the value).
 SaveSetting strAppName, "Settings\" & sstMain.TabCaption(X), txtData(y).Text, txtData(y+1).Text
Next X

Question by:sirbounty
    LVL 19

    Accepted Solution

    Trim trim... Vroom vroom...

    I think you dont need to loop among the tabs, just among the txtData boxes, maybe something like:

    For y = 0 To txtData.Count -1
       If y Mod 2 <> 0 then
           SaveSetting strAppName, "Settings\" & txtData(y).Tag, txtData(y-1).Text, txtData(y).Text
       End If
    Next y

    Or am I too drunk?  :)

    LVL 67

    Author Comment

    I believe you've got it. :^)

    But, I think I'm rethinking this portion of the project -it's getting me into places that, while they seem to work fine now, may prove more of a headache later...

    I'm quite certain this is the solution though - so thank you - points are yours (go spend 'em on a chainsaw! haha)
    LVL 19

    Expert Comment

    Chainsaw it is, thanks :)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    Port V2 16 35
    Window placement 17 55
    Restricting text box entry from \/:?<>"| 9 50
    JSON Response and request in VB6 application 11 50
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now