dynamically build an array

  • Thread starter Phillll Peeps via .NET 247
  • Start date
P

Phillll Peeps via .NET 247

Hi there, hope you can help

How can i put the contents of the clipboard into a two dimensional array of type double?
i can get the data with:
Dim iData As IDataObject = Clipboard.GetDataObject()

i want to build a dynamic array based on the amount of data in the clipboard

so if i copied the 2 lines:
1 2 3
4 5 6
from excel then i would get a 2 dimensional array like this
dim myArray(2, 2) as double, with the clipboard data in the array at the correct locations (myArray(0,0) = 1..... myArray(2,2) = 1 etc....)
 
J

Joshua Flanagan

You could treat the data on the clipboard as a string, and then use the
String.Split() method. First, split on the row separator (carriage
return/linefeed?), then split each resulting string on the column
separator (space or tab). Then for each element, convert it from a
string to a double (Double.Parse).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top