473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Clipboard to Textbox

Hi,
I have several textboxes, I want to click on one to select it, then click a
button to insert the text from the clipboard into it.
I've tried several ways to do this, but can't figure it out.
Can anyone help! (simply)
Sorry I'm a eejit.,
Raymondo
Jun 27 '08 #1
2 3551

"Raymondo" <ra*****@zyko.co.ukwrote in message
news:T-******************************@bt.com...
Hi,
I have several textboxes, I want to click on one to select it, then click
a
button to insert the text from the clipboard into it.
I've tried several ways to do this, but can't figure it out.
Can anyone help! (simply)
Sorry I'm a eejit.,
Raymondo
A couple of ways.. The first is simplest:

Clipboard.GetText Text1.Text

If you need more control, you can also use the SendMessage method..

'------------ in a module ---------
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Const EM_UNDO = &HC7
Public Const WM_CUT = &H300
Public Const WM_COPY = &H301
Public Const WM_PASTE = &H302

'--------------- in the forms ----------------
'--------- UNDO ----------
gResult = SendMessage(Screen.ActiveControl.hWnd, EM_UNDO, 1, 0)
'--------- COPY ----------
Clipboard.Clear
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_COPY, 1, 0)
'--------- CUT -----------
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_CUT, 1, 0)
'--------- PASTE ---------
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_PASTE, 1, 0)
Just make sure activecontrol can accept the message. You can do a quick test
for example, let's say you have richtext boxes and you want to handle copy
cut and paste strictly on a richtext:

If TypeOf Screen.ActiveControl Is RichTextBox Then...
' accept copy, cut, and paste
Jun 27 '08 #2
Thanks Raoul, It is just a simple program to print envelopes.
The second solution is way above my head, but the first is spot-on.
I'll work with that.
Many thanks for taking the time to answer my question.
Regards,
Raymondo
ra*****@raymondos.com

"Raoul Watson" <Wa*****@IntelligenCIA.comwrote in message
news:_HVXj.1159$pk1.642@trndny07...
>
"Raymondo" <ra*****@zyko.co.ukwrote in message
news:T-******************************@bt.com...
>Hi,
I have several textboxes, I want to click on one to select it, then click
a
button to insert the text from the clipboard into it.
I've tried several ways to do this, but can't figure it out.
Can anyone help! (simply)
Sorry I'm a eejit.,
Raymondo

A couple of ways.. The first is simplest:

Clipboard.GetText Text1.Text

If you need more control, you can also use the SendMessage method..

'------------ in a module ---------
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Const EM_UNDO = &HC7
Public Const WM_CUT = &H300
Public Const WM_COPY = &H301
Public Const WM_PASTE = &H302

'--------------- in the forms ----------------
'--------- UNDO ----------
gResult = SendMessage(Screen.ActiveControl.hWnd, EM_UNDO, 1, 0)
'--------- COPY ----------
Clipboard.Clear
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_COPY, 1, 0)
'--------- CUT -----------
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_CUT, 1, 0)
'--------- PASTE ---------
gResult = SendMessage(Screen.ActiveControl.hWnd, WM_PASTE, 1, 0)
Just make sure activecontrol can accept the message. You can do a quick
test for example, let's say you have richtext boxes and you want to handle
copy cut and paste strictly on a richtext:

If TypeOf Screen.ActiveControl Is RichTextBox Then...
' accept copy, cut, and paste


Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: DataBard007 | last post by:
I have an Access97 application whose form contains many text boxes. What do I have to do in order to copy the contents of one of these text boxes to the clipboard? I want to do this so I can then...
1
by: fs | last post by:
Hi all, I have a page that i need to implement a button that says "Paste to textbox1", which will paste the text content in clipboard to a textbox control on postback. How can I get values from...
2
by: Wayne Wengert | last post by:
I am trying to copy the text from a textbox to the clipboard. I saw some code posted earlier for Pasting from the clipboard so I modified it for copy but it is not working (see code below). When I...
4
by: Wayne Wengert | last post by:
I have an aspx page on which I am trying to copy the contents of a textbox to the client clipboard when the users clicks a button. The button code is as follows:...
3
by: mamatha | last post by:
Hi I have one VB application,in that one form consits of textbox. Textbox conatains some data,i want to copy and paste that data into another application without using clipboard oprations.How...
2
by: Steve | last post by:
Hi all, Is it possible to disable pasting from the clipboard into a textbox ?? I can't find a property for it but I guess it must be possible. thanks Steve
8
by: serge calderara | last post by:
Dear all, I have an treeview control with different node object, I would like to implement the Copy/Paste function of an object . For that I am using the folowing function to copy teh object to...
19
by: Jeff | last post by:
....working with visualweb.net 2005 and vb. ....trying to simply copy the contents from a textbox to the clipboard. I've looked at a large number of places on line and they give me various...
3
by: Jaez | last post by:
As a newbie to javascript and asp.net 2 I have come across a problem related to the windows clipboard. I have written an application in vb6 which collects data and puts it on the user's...
8
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.