
accessing clipboard using vb 6.0
This should do it:
'This function returns a string array
Private Function LoadFromClipboard() As String()
Dim sText As String
Dim sRows() As String 'Array
'Get the data, if any
If Clipboard.GetFormat(vbCFText) Then
sText = Clipboard.GetText(vbCFText)
End If
'Assuming the rows have CR/LF
'this will split them into an array, if
'not then the entire string will be
'returned in array element (0)
sRows = Split(sText, vbCrLf)
LoadFromClipboard = sRows
End Function
'Sample of calling the function:
Private Sub Command1_Click()
Dim lIdx As Long
Dim sTextRows() As String 'Array
'Call the function to get the clipboard text
sTextRows = LoadFromClipboard()
'Loop through the returned array
For lIdx = LBound(sTextRows) To UBound(sTextRows)
'Print them to the debug window,
'for now just to see the results.
Debug.Print sTextRows(lIdx)
Next
End Sub
Hope this helps,
Rocky Clark (Kath-Rock Software)
Quote:
> i (computer geek but newbie programmer) am trying to write a simple
program
> which accesses
> data from another application via DDE link. the problem is that some of
the
> data is saved to the clipboard by the other application, and i need to be
> able to access it, including the ability to
> access the individual rows separately. (i'm sure the last part could be
> easily worked
> around if that wasn't possible)
> the format of the clipboard data will never change, just the values. a
> sample, in it's entirety, is:
> 01 APR01 04/21/01 100 100 40.000000 79.139999 40
> 02 MAY01 05/19/01 100 100 40.000000 79.139999 145
> 03 JUL01 07/21/01 100 100 40.000000 79.139999 235
> 04 OCT01 10/20/01 100 100 40.000000 79.139999 330
> 05 JAN02 01/19/02 150 100 40.000000 79.139999 593
> 06 JAN02 01/19/02 100 100 40.000000 79.139999 430
> 07 JAN03 01/18/03 100 100 40.000000 79.139999 699
> would anyone be able to help me access this clipboard data and pull them
> into my application?