Solved

Select all text in a multiline textbox

Posted on 2003-11-12
4
692 Views
Last Modified: 2010-05-01
I have a text box with multiple lines of characters
i have a command button

i need the command button
to select all the text in the textbox
and copy it to memory /  (clipboard) /(ctrl + c)

so that i can just paste it into another program
can i do this if a the textbox is replaced with a label?




0
Comment
Question by:jxharding
4 Comments
 

Assisted Solution

by:twili
twili earned 50 total points
ID: 9730858
Put these lines under your cmd-button:

ClipBoard.Clear      ' Clear Clipboard.
Clipboard.SetText Textbox.Text, vbCFText      ' Put text on Clipboard (txt-format).

/O.
0
 

Accepted Solution

by:
deathman5 earned 40 total points
ID: 9731112
To Select All Test1:

Text1.SelStart = 0         'start position is at the beginning
Text1.SelLength = Len(Text1.Text)  'length is all available text

To Copy All Text1 To Clipboard:

Clipboard.Clear
Clipboard.SetText Text1.Text

hope it help :)
0
 
LVL 5

Assisted Solution

by:ennixo
ennixo earned 35 total points
ID: 9731131
and to copy a label's text (caption) to the clipboard :

Clipboard.Clear
Clipboard.SetText LabelName.Caption
0
 

Author Comment

by:jxharding
ID: 9737402
all answers working , thank you, before i split the points,
if i have the following in the textbox


line1
line2
line3
line4

and i only select line2 and line3 via dragging  & holding the mouse over it, is the only way
i can copy this selected text by sending sendkeys ctrl & C?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now