First you need to undergo some tests to measure your hormone levels. At 40,its possible that your egg reserve is diminished. You need to get some test like LH,FSH,AMH done to determine you status. After that if levels are normal, you will need medication to regularise your periods and induce ovulation. You should see a infertility
specialist for guidance.