Okay, I am trying to extract text from a text box and redisplay it into labels. Specifically, when the user types in an address, say 123 W Elm, I want to click a button and have the "123" print in one label, the "W" to display in a second label, and finally have the "Elm" display in another. I have spent several hours playing with indexof, and substring methods, but am not quite able to do what I want....any ideas?

Recommended Answers

All 2 Replies

string address = "123 w elm"; //so here u would just change to address =                                         /                               //textbox1.Text
         
            string[] myArray = address.Split(' ');

            foreach (var item in myArray)
            {
                label1.Text = myArray[0];
                label2.Text = myArray[1];
                label3.Text = myArray[2];
            }

Something like the above

It works!!!! Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.