From the diagram:
AB + BC = AC
we know that AC = 42, therefore:
AB + BC = 42 ..............> equation I
We know that the ratio AB:BC is 3:4. This means that:
AB/BC = 3/4
4AB = 3BC
AB = (3/4) BC ...............> equation II
Substitute by equation II in equation I to get BC as follows:
(3/4) BC + BC = 42
1.75 BC = 42
BC = 24
Substitute with the value of BC in equation II to get AB as follows:
AB = (3/4) * 24 = 18