CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Location
    In the present
    Posts
    80

    [RESOLVED] diminishing list

    Thanks in advance.

    I am having issues figuring out how to implement a diminishing list (that's what I am calling it).

    I want to ready a list of names from a table into something (an array, listview,etc) and then be able to populate a textbox one name at a time so that a name can be assigned something by a button click, and then it will load the next name in the list. At the end of the list it will check and reload a list. The list is of unknown length.

    I am not sure how to do this type of function.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: diminishing list

    Maybe you want it to make you a cup of coffee?
    Code:
    so that a name can be assigned something by a button click,
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: diminishing list

    What have you got so far?
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  4. #4
    Join Date
    Jul 2007
    Location
    In the present
    Posts
    80

    Re: diminishing list

    This is my pseudo code

    What do you think

    Code:
    public int i = 0;
    
    read data into an array
    
    get the number of objects in array and set to i
    
    private void button_click()
    {
          while (number of objects in array != i+1)
         {
             textbox1.text = stringArray[i].toString();
          }
         i++
    }
    its kinda rough because I am not sure how to go about this.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: diminishing list

    The textbox will overwrite so fast the only entry you'll be able to read is the last one.

    If you need to cycle through the array entries on each button click, store the current index to the array as a class field or property.

    When you click the button, use the current index to access the array and set the textbox text. Then increment the current index (for next time).

  6. #6
    Join Date
    Jul 2007
    Location
    In the present
    Posts
    80

    Re: diminishing list

    Figured it out

    This is out I implemented the solution
    void Button_Click(object sender, EventArgs e)
    {
    //do stuff
    ListProgression(); //increments names by one
    }

    private void ListProgression()
    {
    string[] name ={ "Mark", "Beth", "Alex", "Spade", "John", "Bethany", "Caleb", "Connor", "Mike", "Ryan", "Justin", "Amy", "James" };

    int NumberofNames = name.Length;

    if (i != NumberofNames)
    {
    this.label3.Text = name[i];
    i++;
    }
    else
    {
    MessageBox.Show("end of list");
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured