Hi Everyone,

Please help me how to get the perfect straight line in mschart.also to get the R2 of the the slope and y-intercept.here is my code.
here is the number to input to test the code:

conc1(0)=0
conc1(1)=1
conc1(2)=5
conc1(3)=10
conc1(4)=20

abs1(0)=0.0011
abs1(1)=0.0226
abs1(2)=0.1320
abs1(3)=0.2531
abs1(4)=0.0000

here's my code:


Private Sub ABS1_KeyPress(Index As Integer, KeyAscii As Integer)
Dim s0, s1, s2, t0, t1 As Double
s0 = 0
s1 = 0
s2 = 0
t0 = 0
t1 = 0

Select Case Index
Case 0:

If KeyAscii = 13 Then
ABS1(1).SetFocus
End If
Case 1:
If KeyAscii = 13 Then
ABS1(2).SetFocus
End If
Case 2:
If KeyAscii = 13 Then
ABS1(3).SetFocus
End If
Case 3:
If KeyAscii = 13 Then
ABS1(4).SetFocus
End If
Case 4:
If KeyAscii = 13 Then
'How to get the data for the slope/y intercept computation
For X = 0 To 4
s0 = s0 + 1
s1 = s1 + CONC2(X)
s2 = s2 + (CONC2(X) * CONC2(X))
t0 = t0 + ABS2(X)
t1 = t1 + (CONC2(X) * ABS2(X))
''Plot Graph

Next
AnalyzerInc ' call graph
SlopeOrig = Format((s0 * t1 - s1 * t0) / (s0 * s2 - s1 * s1), "0.#000") 'slope formula M
YinterceptOrig = Format((s2 * t0 - s1 * t1) / (s0 * s2 - s1 * s1), "0.#000") 'Yintercept formula B
SlopeCorrected = Format((s0 * t1 - s1 * t0) / (s0 * s2 - s1 * s1), "0.#000")
Ycorrected = Format((s2 * t0 - s1 * t1) / (s0 * s2 - s1 * s1), "0.#000")
'Regression Formula y = Mx + b
RsquareOrig = Format((SlopeOrig * s0) + YinterceptOrig, "0.#000")
RsquareCorrected = Format((SlopeCorrected * s0) + Ycorrected, "0.#000")
End If
End Select
Graph(0, 2) = ABS2(0)
Graph(1, 2) = ABS2(1)
Graph(2, 2) = ABS2(2)
Graph(3, 2) = ABS2(3)
Graph(4, 2) = ABS2(4)
MSChart1.ChartData = Graph
MSChart2.ChartData = Graph

For Y = 1 To 5
MSChart1.Row = Y
MSChart1.RowLabel = CONC2(Y - 1)
MSChart2.Row = Y
MSChart2.RowLabel = CONC2(Y - 1)

Next
'i got this slope and y intercept to the member of this forum also. thanks to him but i cant understand his R2 formulw(y=mx-b) i dont know where to get the x value.

Please help me to get the prefect line after removing the abs3(4)(abs3 is where the computation displayed)also how to get the regression or R2. Thanks

Note: I use line in chart..cause when i used the xy scattered the negative value did'nt plot on the last column instead it plot on the first row negative value.