I have a VB program that produces reports by sending text to various list boxes.
I want to add the option to have the reports sent to the clipboard. I imagion most users would then want to paste the information into a spreadsheet.
I have figured out that adding chr$(13) to the end of each line of text will make the text in the clipboard appear on the next line.

1. Is there a character I can add to the string that would make the next part of the string (when pasted into a spreadsheet) appear in the next spreadsheet column.

2. Is there an easy way to send all the text that is already in the list box to the clipboard, or will I have to create a huge string to do this.

Thanks.

Hello, I have found out the answer to my first question. You put chr$(9) in the string, then the next bit of the string appears in the next column. CHR$(9) is the tab character. Anyone able to answer my second question though. Any other tips regarding sending text to the clipboard welcome.

You'll have to create a huge string. As far as I can tell, updating the clipboard with VB6 overwrites what was there previously. Just like if you keep opening a file for output instead of append. The easy solution is to have 1 variable that keeps getting concantenated during a loop, and then assign the clipboard the value of the variable....

Yes, It appears that each time you send text to the clipboard (clipboard.settext Astring$) the previous text is deleted, so adding to it line by line would only leave the last line there! Seems that assembling a huge string is the only obvious option. I already have the code for sending the reports to a listbox, so that will help. I checked out how big a string can be in VB5 and in help is says approx. 2 billion characters so no problem there. Some of the reports will be several thousand charactes long. I hope the clipboard does not have a low limit though!

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.