By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Join multiple rows in VB

P: 1
Hi

My name is Bjorn and I have a VB question:

How do I join multiple rows in VB?
Example
I have the data in a format like this:

Expand|Select|Wrap|Line Numbers
  1.     result 1    result 2
  2. 11104    8    
  3. 11104        1
  4. 11105    2    
  5. 11105        4
I would like to have the data like this

Expand|Select|Wrap|Line Numbers
  1.     result 1    result 2
  2. 11104    8    1    
  3. 11105    2    4
I really appriciate any help I can get. I am not well oriented in VB
Thanks
Bjorn
May 2 '07 #1
Share this Question
Share on Google+
2 Replies


Dököll
Expert 100+
P: 2,364
Hi

My name is Bjorn and I have a VB question:

How do I join multiple rows in VB?
Example
I have the data in a format like this:

result 1 result 2
11104 8
11104 1
11105 2
11105 4

I would like to have the data like this

result 1 result 2
11104 8 1
11105 2 4

I really appriciate any help I can get. I am not well oriented in VB
Thanks
Bjorn
Hello, Bjorn!

Is this VB 6 you are refering to?

Welcome!

Dököll
May 3 '07 #2

Expert 5K+
P: 8,434
Is this VB 6 you are refering to?
And what sort of data are we referring to? Is this something in a text file? An array? An Excel worksheet? A database? A big textbox? Something else?

A general algorithm to handle this might be something along the lines of...
Expand|Select|Wrap|Line Numbers
  1. Read each line
  2.   If the first part is the same as the previous line
  3.     Add the second part to our output line
  4.   Else
  5.     Write out the output line (if any)
  6.     Clear the output line
  7.     Put the current line into the output line
  8.   End If
  9. End of loop
May 3 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.