## Calculate a possible value of year 2018 (trend/slope value?)

## Calculate a possible value of year 2018 (trend/slope value?)

(OP)

**I just have post the question in VBA but really i need in vb6, sorry.**

Have a label:

L2012.caption=23

L2013.caption=4

L2014.caption=23

L2015.caption=4

L2016.caption=11

L2017.caption=0

Is possible to estimate the value for the year 2018?

note:

The various labels contain the values of the work done in my office from the old years.

How to?

Grazie

## RE: Calculate a possible value of year 2018 (trend/slope value?)

## RE: Calculate a possible value of year 2018 (trend/slope value?)

## CODE

`Option Explicit Option Base 1 Private Sub Command1_Click() Dim fred(6) As Double fred(1) = 23 fred(2) = 4 fred(3) = 23 fred(4) = 4 fred(5) = 11 fred(6) = 0 MsgBox TrendNextPoint(fred) End Sub Public Function TrendNextPoint(fred() As Double) As Double TrendNextPoint = Trend(fred, UBound(fred) + 1) End Function Public Function Trend(arrSample() As Double, newpoint) As Double Dim lp As Long Dim meanX As Double Dim meanY As Double Dim xy As Double Dim xx As Double Dim m As Double Dim b As Double For lp = 1 To UBound(arrSample) meanX = meanX + lp meanY = meanY + arrSample(lp) Next meanX = meanX / (lp - 1) meanY = meanY / (lp - 1) For lp = 1 To UBound(arrSample) xy = xy + (lp - meanX) * (arrSample(lp) - meanX) xx = xx + (lp - meanX) * (lp - meanX) Next m = xy / xx b = meanY - m * meanX Trend = newpoint * m + b End Function`

## RE: Calculate a possible value of year 2018 (trend/slope value?)

TKS!

The code work a like a charm!

tks for patience.

but...

i need to rapresent the trend result with a wingding 3 font in a subitems cell of listview similar:

good trend green fonts color, arrow up

no good trend red font color, arrow down

how to?

## RE: Calculate a possible value of year 2018 (trend/slope value?)