English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

.
Specifically, I want to create a memory resident program which will do a COPY to the Clipboard by **merely highlighting** text (ready to PASTE) without the need for CTRL-C.

Background: Many years of programming, but fairly new to VB.
Additional question: is there an existing freeware utility for the above? (I wish to learn about mem resident programming in VB regardless).

TIA! :)
Ballpeen

2007-02-19 10:03:34 · 2 answers · asked by Ballpeen 1 in Computers & Internet Programming & Design

2 answers

If you intend to capture text from other applications (this is why you probably refer to mem resident), I don't think it can be done at all, certainly not VB.
The closest would be that you have an background app that monitors whether Shift is held down, then checks the active window and sees what is selected. This will work fine for text boxes and maybe a set of other controls, but to support other sources as Word, Excel etc you would need a HUGE select case. I'd recommend only VC++ for the purpose, VB would be a bottleneck for the system.

2007-02-20 07:20:51 · answer #1 · answered by BataV 3 · 0 0

There is a way in VB to copy the highlighted text to the clipboard. Here are some code that might be useful for you:

Sub Main()
Dim myString As String
myString = "1234" // This can be your highlighted text
//Clear the contents of the Clipboard.
Clipboard.Clear
// Copy selected text to Clipboard.
Clipboard.SetText myString
End Sub

Of you can use the following piece of code:
Sub mnuCut_Click ()
' empty the clipboard
Clipboard.Clear
' copy the selected text to the clipboard
Clipboard.SetText txtBox.SelText
' and remove the selected text
txtBox.SelText = ""
End Sub

Sub mnuCopy_Click ()
' empty the clipboard
Clipboard.Clear
' and copy the selected text to the clipboard
Clipboard.SetText txtBox.SelText
End Sub

Sub mnuPaste_Click ()
' paste clipboad text into document
txtBox.SelText = Clipboard.GetText()
End Sub

Hope this helps

2007-02-19 12:42:24 · answer #2 · answered by A. C 1 · 0 0

fedest.com, questions and answers