|
-
May 27th, 2005, 06:15 AM
#1
Thread Starter
Addicted Member
Code to copy textbox to clipboard
Is there some simple coding i can use to copy the contents of textbox to the clipboard????
-
May 27th, 2005, 06:17 AM
#2
Re: Code to copy textbox to clipboard
What database are you using... if your talking about access you may be able to do it via macros.
Last edited by <ABX; May 27th, 2005 at 06:18 AM.
Reason: Overtired....
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
May 27th, 2005, 07:29 AM
#3
Thread Starter
Addicted Member
Re: Code to copy textbox to clipboard
I'm using MSAccess 2003.
I've kinda cheated, but then it works....
VB Code:
Dim copypasteUpdater As String
copypasteUpdater = [ContractorName].Value & vbCrLf
If [Address].Value <> "" Then copypasteUpdater = copypasteUpdater + [Address].Value & vbCrLf
If [Town].Value <> "" Then copypasteUpdater = copypasteUpdater + [Town].Value & vbCrLf
If [County].Value <> "" Then copypasteUpdater = copypasteUpdater + [County].Value & vbCrLf
If [PostCode].Value <> "" Then copypasteUpdater = copypasteUpdater + [PostCode].Value
[txtCopyPastebox].Value = copypasteUpdater
txtCopyPastebox.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
I made txtCopyPastebox textbox 0cm wide and very small, and then put it beside my copy button.
would have preferred to copy copypasteUpdater string direct to clipboard, but nevermind!
-
May 27th, 2005, 08:44 PM
#4
Re: Code to copy textbox to clipboard
This example uses the SetText method to copy text from a text box to the Clipboard. To try this example, paste the code into the Declarations section of a form with a text box named Text1, and then press F5 and click the form.
VB Code:
Private Sub Form_Click ()
Const CF_TEXT = 1 ' Define bitmap format.
Dim I, Msg, Temp ' Declare variables.
On Error Resume Next ' Set up error handling.
Msg = "Type anything you like into the text box below."
Text1.Text = InputBox(Msg) ' Get text from user.
Msg = "Choose OK to copy the contents of the text box "
Msg = Msg & "to the Clipboard."
MsgBox Msg ' Display message.
ClipBoard.Clear ' Clear Clipboard.
Clipboard.SetText Text1.Text ' Put text on Clipboard.
If Clipboard.GetFormat(CF_TEXT) Then
Text1.Text = "" ' Clear the text box.
Msg = "The text is now on the Clipboard. Choose OK "
Msg = Msg & "to copy the text from the Clipboard back "
Msg = Msg & "to the text box."
MsgBox Msg ' Display message.
Temp = Clipboard.GetText(CF_TEXT) ' Get Clipboard text.
For I = Len(Temp) To 1 Step -1 ' Reverse the text.
Text1.Text = Text1.Text & Mid(Temp, I, 1)
Next I
Else
Msg = "There is no text on the Clipboard."
MsgBox Msg ' Display error message.
End If
End Sub
-
Jun 2nd, 2005, 09:20 AM
#5
Thread Starter
Addicted Member
Re: Code to copy textbox to clipboard
I'm using MSAccess 2003.
the "Clipboard" is not a recognised object in Access.
if I remove the
VB Code:
On Error Resume Next ' Set up error handling.
line then I get an error saying "Run-time Error 424, Object Required."
at the
VB Code:
ClipBoard.Clear ' Clear Clipboard.
Line.
Is there a way of making the clipboard work???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|