@greenestamps just showed you one good way to start and to solve the problem.
Another way is THIS
Let x be the number of boys.
Then the number of girls is (340-x), and you can write the proportion
= .
From the proportion,
9*(340-x) = 8x
9*340 = 8x + 9x
9*340 = 17x
Next divide both sides by 17
9*20 = x
x = 180 boys. ANSWER