First you must expand the brackets,
7x + 7 + 8x -12 = 40
Then take your numbers (without the x's) and put them on the opposite side of the equals sign. Remember once you swap the sides a + will turn into a - and a - will turn to a +
7x + 8x = 40 -7 + 12
Then simplify,
15x = 45
Finaly divide 45 by 15,
(Sadly there's no divide sign on my phone)
15 x 3 = 45
This means,
x = 3