 |
 |

08-11-2006, 12:04 PM
|
|
Freshman
|
|
Join Date: Jun 2006
Posts: 25
|
|
Copy and Paste Function
|
Im trying to write my own copy and paste function for my program, but I seem to be having some problems starting off.
I just want to enquire this first, how does a typical copy function work? Whenever, we press ctrl+c, where are the text words copied to? a text file or maybe a string array?
In another matter, is there a built-in function to detect where the running program currently has its 'focus' on? Its like I want to know on which form is my focus at.
|
|

08-11-2006, 01:39 PM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,882
|
|
|
1. Whatever you like, normal you would keep it in memory by placing it on the ClipBoard
2. ActiveForm, ActiveControl
|
|

08-11-2006, 01:41 PM
|
 |
Multi-Technologist
Super Moderator * Expert *
|
|
Join Date: May 2004
Location: Michigan
Posts: 3,734
|
|
|
The .Clipboard object gives you direct access to the Windows clipboard and usually prevents needing to write your own functions. Just be sure that you do not programatically corrupt the clipboard contents, otherwise users will get unexpected results when they are using the clipboard elsewhere.
For which form has focus, look into Screen.ActiveForm.
|
|

08-14-2006, 11:12 AM
|
|
Freshman
|
|
Join Date: Jun 2006
Posts: 25
|
|
|
I still seem to be having problem with this. I've tried using Flyguy's example code on highlighting multiple cells at once and tried using:
Clipboard.SetText Screen.ActiveControl.Text.
It seems what is being copied is only on the text of cell being focused on. How can i copy text of multiple cells that is being highlighted? I intend to do something like the Excels copy and paste function.
|
|

08-14-2006, 02:47 PM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,882
|
|
|
You have to give more information.
Are you referring to a flexgrid control on some form?
|
|

08-14-2006, 08:31 PM
|
|
Freshman
|
|
Join Date: Jun 2006
Posts: 25
|
|
|
Oh yes. It is for the flexgrid. I must have missed that out.
I intend to copy any highlighted cells into the clipboard. But I could only copy the text of the cell being focused on. How can i copy text of multiple cells that is being highlighted?
|
|

08-15-2006, 01:10 AM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,882
|
|
|
Use the .Clip property of the FlexGrid
|
|

08-15-2006, 04:35 AM
|
|
Freshman
|
|
Join Date: Jun 2006
Posts: 25
|
|
Just a simple question.
I found this while browsing through the net.
http://www.expressnewsindia.com/c4/ex1/C1000.html
Private Sub EditPaste()
'Insert Clipboard contents
If Len(Clipboard.GetText) Then MSFlexGrid1.Clip = _
Clipboard.GetText
End Sub
I can't seem to comprehend this coding. Normally when I use the IF statement, it would always end with a '='. In this case , it does not have an equals. How does this work? Besides that, this line :
MSFlexGrid1.Clip = _
Clipboard.GetText.
What is the ' _ ' for? normally i would just put
MSFlexGrid1.Clip = Clipboard.GetText. Please do explain. thanks
|
|

08-15-2006, 05:15 AM
|
|
Regular
|
|
Join Date: Nov 2004
Posts: 98
|
|
I use:
Code:
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText FlexGrid.Text
End Sub
mnuCopy is a control in a popup menu that appears when you right click on the flexgrid.
|
__________________
If (Online = True) Then
Shell "firefox.exe -remote openURL( www.xeweb.net)"
End If
|

08-15-2006, 05:21 AM
|
 |
Junior Contributor
|
|
Join Date: Mar 2004
Posts: 357
|
|
the If construct evaluates a Boolean expression
Code:
If [Boolean Expression] Then
so you will commonly use it
Code:
If strMyName = "bushmobile" Then
where strMyName = "bushmobile" is evaluated to True or False.
In VB False = 0 and True = Not False. So if Clipboard.GetText = "", then Len(Clipboard.GetText) = 0 and it is evaluated to False.
Conversely, if there is some text in Clipboard.GetText then Len(Clipboard.GetText) will return a number other than zero and hence be evaluated to True.
The underscore (_) is just used to break long lines for readability.
|
|

08-15-2006, 05:28 AM
|
 |
Junior Contributor
|
|
Join Date: Jun 2006
Posts: 228
|
|
Quote:
|
Originally Posted by fabbie
I can't seem to comprehend this coding. Normally when I use the IF statement, it would always end with a '='. In this case , it does not have an equals. How does this work? Besides that, this line :
MSFlexGrid1.Clip = _
Clipboard.GetText.
What is the ' _ ' for? normally i would just put
MSFlexGrid1.Clip = Clipboard.GetText. Please do explain. thanks
|
An If statement evaluates the following conditions as True or False. In mathematical terms, 0 is False, anything else is True. This form of the If statement is a shortcut for:
Code:
If Len(Clipboard.GetText) <> 0
The '_' is a continuation character. It tells the compiler that the statement continues on the next line. It is used to make the code more readable and to stop you having to scroll right to read the end of a long statement.
MSFlexGrid1.Clip = _
Clipboard.GetText.
&
MSFlexGrid1.Clip = Clipboard.GetText
Are exactly the same to the compiler.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|