?
Solved

Select all text in a multiline textbox

Posted on 2003-11-12
4
Medium Priority
?
716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Assisted Solution

by:twili
twili earned 150 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 120 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 105 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 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