2 dimensional array-->1 dimensional array

S

skavan

Hi,

Trying to wrap my head around the following problem.
Let's say I have a 2 dimensional array:

Dim arrS(3,4) As String

I want to copy the subarray arrS(0,) to a new array arrLoop(4) As
String.

How can one do this?

In fact, I may be taking the wrong approach entirely, so I'll spell out
my use case:
1. Let's say I have 4 lines of text.
2. Each line has up to 5 pre-defined parameters (words) in it, in a
non-predefined order.
3. I scan the line, taking note of when a predefined word is found and
what its word position is.
4. I repeat this for each line.

at the end of the process, I want to know which parameter order was
most commonly found across the lines of text.

Any ideas on how to approach this?
 
M

Maate

I want to copy the subarray arrS(0,) to a new array arrLoop(4) As
string.

Somewhat like:

for i as integer = 0 to ArrS.GetUpperbound(1)
arrLoop(i) = ArrS(0, i)
next

?????

But I'm not sure, i understand your problem... Is your text somewhat
like this:

aaaa bbbb cccc dddd eeee
ffff gggg hhhh iii jjjj
kkkk bbbb cccc llll
bbbb mmmm nnnn oooo

- And your problem is to detect the most common parameter ("bbbb") and
its position in the text: (0, 1);(2,1);(3,0) ? Or have I misunderstood?
 
S

skavan

a) Is there a way of copying the array without going through an
expensive loop?
I was hoping that simply saying arrLoop = ArrS(0,) - but it doesn't
work.

b) Image the 5 strings are:
aaaa bbbb cccc
xxxx yyyy zzzz
dddd eeee pppp
eeee gggg kkkk
aaaa cccc bbbb

Also assume that:
Group1: aaaa, dddd
Group2: bbbb, eeee
Group3: xxxx, yyyy,zzzz
Group4: gggg, kkkk, pppp, cccc

I want to know what the most common Group in word position 1 is.
So in the example above, we have:
Group 1 = 3, Group2 = 1, Group3 =1 for the first word position. I want
a computationally efficient way of determining that its Group 1 with 3
hits, followed by Group2 and 3 with 1 hit apiece...and then the same
thing for Word2 and Word3.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top