Populating an array from a memo box
I want to have a control on my form where I can paste in a big list of words, up to 10,000 lines long. Then I want to perform some text manipulation.
e.g. add/remove " or [] characters to each line. Or add a text phrase to the end of each line.
I figure the best way to do this would be to read each line into an array.
What control would be best? Just a text control or is there a memo field like in MS Access vba? How would I read each line into an array? Would reading into an array be the best way to do this?
Thanks,
Jon
Re: Populating an array from a memo box
a standard textbox control should work fine for you.
Do you want to read each line into an array? or each word? you will have to split the text on something, like a carrage return.. but line breaks may not match exactly how you see things in the textbox.. because the textbox will wrap a line of text even if its not the end of the line, but the control is smaller than the text for that line (just like notepad does with word wrap)
so you need to know exacty how you want to split things up.
Re: Populating an array from a memo box
If you are using a multiline textbox then you can use the lines property in order to access each line of text in the control. An example of accessing and modifying the lines property for a richtextbox control was posted by me in the below thread:
http://www.vbforums.com/showthread.php?t=414692
Of course, you can always use a listbox if you are just making a list of words...
Re: Populating an array from a memo box
I want to read each line into an array. There will never be more than 5 words in a line so word wrap won't be an issue.
Re: Populating an array from a memo box
Then look at the link I posted for an example for the RichTextBox.. its the same for a textbox. Copying the contents to a temp array, modifying the info, and then assigning it back to the lines property...