tags:

views:

55

answers:

3

VB6: I am able to write to clipboard using Clipboard.SetText. But I want to write in steps. Like first String1. Then append String2 after String1. Is there any way to do that?

A: 

You could just write your first bit, then later read the clipboard and append to what you read and set the text again...the only issue is that some other app might write to the clipboard during this time.

Douglas Anderson
+3  A: 

Keep track of what you've written to the clipboard with another string, which I'll call ClipboardString.

You can set ClipboardString equal to String1, then set the clipboard to ClipboardString. Then append String2 to ClipboardString and set the clipboard to ClipboardString. And so on...

Doing it this way will eliminate any possible problems with other programs overwriting the clipboard before you're done appending your strings.

Rob
+3  A: 

Rob's answer is good. My additional advice is to always use Clipboard.Clear before using Clipboard.SetText. Otherwise, the user might not be able to paste your text.

E.g. if the user first copies "text one" in Word, then uses your app to copy "text two", then uses Paste in Word: it will paste "text one". This happens because the clipboard still contains the formatted string "text one" from Word, and Word uses that formatted text in preference to your unformatted text.

MarkJ