Parameter format for the Slope( ) function from .NET

D

Derrick Repep

Hi,

I have created a .NET application that creates an Excel object in-memory. I
am trying to use the Slope( ) function, but it just doesn't seem to work no
matter what I use for arguments.

Scenario:
Given three collinear data points {(1,1), (2,4), (3,7)}, you want to
determine the equation for the line. In a cell in an Excel spreadsheet, you
can put the following formula:

=Slope({1,4,7}, {1,2,3})

This will be evaluated to "3", because the formula of the line described by
those three points is
y = 3x -2

In VB.NET, you can access this function from the
ExcelApplication.WorksheetFunction namespace; however, I cannot figure out
how to represent the Y-values and X-values so that the function will accept
them. The Slope( ) function lists each of its arguments as having an
"Object" type, which tells me nothing about what it REALLY wants. The Excel
spreadsheet version (above) uses curly braces around the value sets to
denote an array of values; that is the part I can't figure out. Arrays and
arraylists don't work, and neither do the curly braces in a string.

Anyone run into this and, if so, how did you solve it?

Thank you in advance,
Derrick
 

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