Results 1 to 40 of 84

Thread: [RESOLVED] VB 2010: Array displayed in listbox to textboxes for editing then back to array&.txt?

Threaded View

  1. #11
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: VB 2010: Array displayed in listbox to textboxes for editing then back to array&.

    You may not even have to assign them manually, if all your TextBox design names start with "TextBox" and then followed by a number, then you could just do this:

    *This assumes all your Textboxes are on the main form. And the ones you want to add the text to, are in order based on their design number in "TextBox#" and that each of these Textboxes are named similarly by "TextBox#" in your designer.*

    vbnet Code:
    1. Dim stock As String() = stockArray.First(Function(objArr) objArr(0) = ListBox1.SelectedItem.ToString)
    2. For i As Integer = 0 To stock.Length - 1
    3.     Me.Controls("TextBox" & (i + 1).ToString).Text = stock(i)
    4. Next

    I'm not arguing, i'm just trying to help out in this thread. It's good for people to try to understand good habits, and that's what i'm trying to point out here. Usually I see people making things harder than they need to be when they ask for help, but that's part of the reason why they request assistance.

    If you want a way to loop through the stockArray and add items to text i'll switch to a solution using that method, but I'm trying to make things easier for you, that's all.

    ~Ace
    Last edited by AceInfinity; Aug 19th, 2012 at 04:06 PM.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

Tags for this Thread

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