473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VB Trend Function - like Excel

Hi - is there a function (or does anyone have any code) which replicates
the TREND function in Excel:

TREND(y, ,newx)

I work in a call centre, and would like to predict the grade of service
at the end of the month - based on the grade of service for each day of
the month so far. I would like to have this contained within my vb.net
web application, and not have to export data to Excel, then add the
formulas, then create the report and reupload to our management portal.

Any help/suggestions would be really appreciated.

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***
Nov 11 '08 #1
1 11498
Hi - found it, in case anyone's interested:

Public Sub LRegression(ByVal X() As Double, ByVal Y() As Double, ByRef
Slope As Double, ByRef YInt As Double)
Dim dblWork() As Object
Dim dblXMean As Double
Dim dblYMean As Double
Dim dblSumXX As Double
Dim dblSumXY As Double
Dim dblSumYY As Double
Dim dblSlope As Double
Dim dblYInt As Double
Dim lVCnt As Long
Dim i As Long
lVCnt = UBound(X)
If (lVCnt <UBound(Y)) And (lVCnt 1) Then _
Err.Raise(17, , "Arrays must match in number of vectors and
have a count greater than 1.")

lVCnt = lVCnt + 1

ReDim dblWork(lVCnt)

For i = 0 To lVCnt - 1
dblXMean = dblXMean + X(i)
Next i
dblXMean = dblXMean / lVCnt

For i = 0 To lVCnt - 1
dblYMean = dblYMean + Y(i)
Next i
dblYMean = dblYMean / lVCnt

For i = 0 To lVCnt - 1
dblSumXX = dblSumXX + (X(i) - dblXMean) * (X(i) - dblXMean)
Next i

For i = 0 To lVCnt - 1
dblSumYY = (dblSumYY + Y(i) - dblYMean) * (Y(i) - dblYMean)
Next i

For i = 0 To lVCnt - 1
dblSumXY = dblSumXY + (X(i) - dblXMean) * (Y(i) - dblYMean)
Next i

dblSlope = dblSumXY / dblSumXX
dblYInt = dblYMean - (dblSlope * dblXMean)

Slope = Math.Round(dblSlope, 2)
YInt = Math.Round(dblYInt, 2)
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe | last post by:
I need to add a trend line to a scatter plot (not automatically supported by the charting package) but I don't know how to calculate it. Is there any formulas around for calculating what the trend...
5
by: kux | last post by:
Hello everyone, I hope someone is out here who can help me with a simple calculation... I have a sales data base in access with monthly sales history by product. to make future predictions I...
2
by: GhanaShyam | last post by:
Hi, How can I use the LINEST functionality of Excel in my .NET code. Can I use the Excel interopability dll or should I write the function code? Thanks in Advance GS.
3
by: nikhilton | last post by:
I used trend micros housecall online scanner and it qaurantined alot of important files on my pc i.e. university coursework, its currently in a folder called ".housecall" id be really grateful if...
1
by: Jaime Leivers | last post by:
Here's a median function in access that you can call in any query. You could change this to any excel function you wanted. Most people can find the windows help file that says how to call an excel...
29
by: Xah Lee | last post by:
Computer Language Popularity Trend This page gives a visual report of computer languages's popularity, as indicated by their traffic level in newsgroups. This is not a comprehensive or fair...
0
by: bubbles | last post by:
Access 2003 front-end with SQL Server 2005 backend. I have charts in the Access application, and these charts have polynomial trend lines. Is there a way, programmatically, to define the...
0
by: Bhargav | last post by:
How to import Web Trend report(for example 'Page Hit' report) programatically with C# (When I select 'Page Hit Report' from drop down list on .aspx page and click on 'Run' button 'Page Hit Report'...
3
by: keirnus | last post by:
Hello once again... I made a function in Excel. The function does some error checking within the Excel file. To be easy for me, I want my code in MS Access to simply call the function in Excel....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.