+ Reply to Thread
Results 1 to 3 of 3

How to display 4 order Polynomial equation from the Excel in VB6 ?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    london,england
    MS-Off Ver
    Excel 2003
    Posts
    2

    How to display 4 order Polynomial equation from the Excel in VB6 ?

    I can display the Polynomial equation by the following code, onething

    unsatisfactory it returns a 2 order Polynomial equation by default. but

    I need to get the 4 order Polynomial equation for further process.

    Your earliest reply will be highly appreciated!

    xlBook.ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlPolynomial, Forward:=0, Backward:=0, DisplayEquation:=True).Select

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: How to display 4 order Polynomial equation from the Excel in VB6 ?

    add

    Order:=4
    to your statement.

  3. #3
    Registered User
    Join Date
    07-28-2010
    Location
    london,england
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: How to display 4 order Polynomial equation from the Excel in VB6 ?

    Quote Originally Posted by teylyn View Post
    add

    Order:=4
    to your statement.
    It works! Thanks!
    Actually my Excel works background because I just want to leverage the equation it returns.

    At the same time, I use a ChartSpace control in foreground to show the same 4 order Polynomial curve with the following code.Same question with the above solved Excel question, the Chartspace control just returns a 2 order Polynomial curve which I prefer that of 4 order. I tried to insert the parameter of " order = 4 " in somewhere of the following code but failed.

    Would you please solved this my last mile project question for me?

    BTW may I hold the " Mark As answer" for a while in case others don't see my this further chartSpace question?

    Anyway I'll " Mark As answer" and start a new thread if my last question can't be solve for some days. thanks for your understanding.

    My chartSpace code as follows:

    Dim chConstants
    Dim axValueAxis
    Dim chtChart1

    Set chConstants = ChartSpace1.Constants

    ' Set the data source of ChartSpace1 to Spreadsheet1.
    Set ChartSpace1.DataSource = Me.sdstPlatevalue

    ' Set a variable to a new chart in Chartspace1.
    Set chtChart1 = ChartSpace1.Charts.Add

    ' Set the chart type.
    chtChart1.Type = chConstants.chChartTypeScatterMarkers


    chtChart1.SetData chConstants.chDimXValues, chConstants.chDataBound, "A1:A5"

    chtChart1.SetData chConstants.chDimYValues, chConstants.chDataBound, "B1:B5"

    Set axValueAxis = ChartSpace1.Charts(0).Axes(0)

    ' The following two lines of code turn off the major and
    ' minor gridlines for the value axis.
    axValueAxis.HasMajorGridlines = False
    axValueAxis.HasMinorGridlines = False

    Set axValueAxis = ChartSpace1.Charts(0).Axes(1)

    ' The following two lines of code turn off the major and
    ' minor gridlines for the value axis.
    axValueAxis.HasMajorGridlines = False
    axValueAxis.HasMinorGridlines = False


    Dim serSeries1
    'Dim chConstants
    Dim tlSeries1Trend

    ' Set chConstants = ChartSpace1.Constants

    ' Set a variable to the first series of the first chart
    ' in Chartspace1.
    Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

    ' Add a trendline to the first series and return
    ' a Trendline object.
    Set tlSeries1Trend = serSeries1.Trendlines.Add

    ' Display the equation used to calculate the trendline.
    tlSeries1Trend.IsDisplayingEquation = False
    tlSeries1Trend.IsDisplayingRSquared = False


    ' Set the trendline to be a polynomial trendline.


    tlSeries1Trend.Type = chConstants.chTrendlineTypePolynomial

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1