PC Review


Reply
Thread Tools Rate Thread

Copying results to clipboard. Is there a better way ?

 
 
Makissk
Guest
Posts: n/a
 
      18th Aug 2008
Inside a userform there is some code that takes a string, does some
calculation, and produces a result. This result needs to be "sent" to the
clipboard, so that the user - if needing it - can paste it in a cell. For
example, the user enters the 12 first digits of a barcode string, the code
calculates the check digit and then concatenates both in order to create the
entire barcode string.
This string is sent to the clipboard, so that the user can paste it in a cell.

In order to do this, i have declared a variable twice, once as a string and
once again as a New Dataobject:

Dim CodeToEvaluate, CompleteCode As String
Dim CC As Integer
Dim CompleteCodeFinal As New DataObject

After the user enters CodeToEvaluate, some calculation is done for CC to be
found, and then

Let CompleteCode = CodeToEvaluate & CC

Complete code is shown to the user with an Msgbox, and then

CompleteCodeFinal.SetText CompleteCode
CompleteCodeFinal.PutInClipboard

It Works OK. BUT i wonder if there is a more "elegant" way to do this.
 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      18th Aug 2008
>> i wonder if there is a more "elegant" way to do this.

No, that's as elegant as it gets.

>>Dim CodeToEvaluate, CompleteCode As String


FYI, that declares CodeToEvaluate as a variant and CompleteCode as a string.
VB does not do it like C.

--
Jim
"Makissk" <(E-Mail Removed)> wrote in message
news:5B501162-3DD7-4A9C-8960-(E-Mail Removed)...
| Inside a userform there is some code that takes a string, does some
| calculation, and produces a result. This result needs to be "sent" to the
| clipboard, so that the user - if needing it - can paste it in a cell. For
| example, the user enters the 12 first digits of a barcode string, the code
| calculates the check digit and then concatenates both in order to create
the
| entire barcode string.
| This string is sent to the clipboard, so that the user can paste it in a
cell.
|
| In order to do this, i have declared a variable twice, once as a string
and
| once again as a New Dataobject:
|
| Dim CodeToEvaluate, CompleteCode As String
| Dim CC As Integer
| Dim CompleteCodeFinal As New DataObject
|
| After the user enters CodeToEvaluate, some calculation is done for CC to
be
| found, and then
|
| Let CompleteCode = CodeToEvaluate & CC
|
| Complete code is shown to the user with an Msgbox, and then
|
| CompleteCodeFinal.SetText CompleteCode
| CompleteCodeFinal.PutInClipboard
|
| It Works OK. BUT i wonder if there is a more "elegant" way to do this.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying to the clipboard Jeff Microsoft VB .NET 18 19th Jan 2007 08:50 AM
Clipboard gets empty by itself, cleared clipboard, copy paste doesn't work, outlook clears clipboard, problems with clipboard - possible solution Jens Hoerburger Microsoft Outlook 0 24th Aug 2006 02:44 PM
Copying to clipboard using Ctrl-C or Clipboard.SetText =?Utf-8?B?S2V2aW4gQnVydG9u?= Microsoft Dot NET Framework 0 28th Jul 2006 01:13 AM
Copying the filtered data to clipboard is copying non-visible rows =?Utf-8?B?U2VldGhhUmFtYW4=?= Microsoft Excel Crashes 10 12th Jul 2006 09:39 PM
Copying to clipboard Arun Microsoft C# .NET 3 17th Mar 2006 10:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:31 AM.