Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

2009luca

Programmer
Jul 27, 2013
222
0
16
IT
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
 
And, from something like:

Code:
[blue]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[/blue]
 
Strongm, i dont know the really name:)

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?



 
You should probably post that as a seperate question. However, the short answer is that the VB6 ListView control has a global setting for the font, so you cannot use a different font for subitems (although you can set colour separately). Nor does the Vb6 ListView support Unicode, so you can't even use Unicode arrows as an alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top