CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Junior Member
Join Date
Sep 2018
Posts
2

## Adding Items From 1 RichTextBox into Different Arrays

I've been struggling to figure out how to do this and hope someone can help. Here is my scenario...

I have a RichTextBox with multiple items inside and the number of items may vary from one day to the next. I also have the option to run my program on either 1, 2 or 3 different threads (each thread will have its own array to work from). Once started, I would like the program to look at how many items are listed in the RichTextBox and then split them up evenly into each individual array.

Here is some code I've been messing around with, but I know I'm way off because I've never done this before. You can tell by the very first line that if I don't have a round number it's not going to work. For example, if I were to put 7 items into the RichTextBox and select 3 threads, the Integer I'm going to get is 2.3333333

Code:
'Get number of items in RichTextBox and divide by number of threads selected to determine how many items should go into each individual array

Dim myitemArray1 As New ArrayList
Dim myitemArray2 As New ArrayList
Dim myitemArray3 As New ArrayList
Dim x As Integer = 1
Dim arrayCount As Integer = 1

For i As Integer = 0 To txtItems.Lines.Count - 1
x = x + 1
End While
x = 0
arrayCount = arrayCount + 1
Next

2. ## Re: Adding Items From 1 RichTextBox into Different Arrays

Your problem has nothing to do with the RichTextBox.
It is just simple mathematics. Try to solve it with a peace of paper and a pencil.
Then learn the basics how to work with integer numbers (integer arithmetic).
Then implement your algorithm in code!

#### Posting Permissions

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