I've drawn a sample of a segment with 10 collinear points.
As you can see they all lie on the same line.
A B C D E F G H I J
Now take a look at all of the possible line segments that you could make beginning with point A.
Segments AB, AC, AD, AE, AF, AG, AH, AI and AJ (9 segments)
Now take a look at point B.
You already counted BA (that's AB)
You have segments BC, BD, BE, BF, BG, BH, BI, BJ (8 segments, one less than 9)
In fact as you keep track from C to I, you will always have one less segment.
A (9 segments)
B (8 segments)
C (7 segments)
D (6 segments)
E (5 segments)
F (4 segments)
G (3 segments)
H (2 segments)
I (1 segment)
Total = 40 different segments in all