Question: Slaying the Jewish males:
Sura 40:23-25 says, "And truly We sent Moses with our revelation and a clear warrant unto Pharaoh and Haman and Qarun, but they said, `A lying sorcerer!' And when he brought them the truth from our presence, they said, `Slay the sons of those who believe with him....'"
From this, we learn that Pharaoh ordered the killing of the sons of the Jews when Moses approached him with the truth. But Sura 20:38-39 says, "When We inspired in your mother that which is inspired, saying, `Throw him into the ark, and throw it into the river....'" This means that Pharaoh commanded his men to kill the sons of the Jews when Moses was a child. Moses had not yet received any revelation from God.
Answer: Two completely different occasions, the first when Moses was born and male babies were to be slayed since the astrologists of Pharoah warned him of the birth of a boy at the year Moses was born who will bring his demise. The second was intimidation of Pharoah to slay the Jewish males as well Moses which he would have succeeded if he was not drowned with his army in the sea.
First occasion: 20:37-40: as a baby:
20:37 "And indeed We conferred a favour on thee another time (before). وَلَقَدْ مَنَنَّا عَلَيْكَ مَرَّةً أُخْرَى
20:38 "Behold! We sent to thy mother, by inspiration, the message: إِذْ أَوْحَيْنَا إِلَى أُمِّكَ مَا يُوحَى
20:39 "'Throw (the child) into the chest, and throw (the chest) into the river: the river will cast him up on the bank, and he will be taken up by one who is an enemy to Me and an enemy to him': But I cast (the garment of) love over thee from Me: and (this) in order that thou mayest be reared under Mine eye.
أَنِ اقْذِفِيهِ فِي التَّابُوتِ فَاقْذِفِيهِ فِي الْيَمِّ فَلْيُلْقِهِ الْيَمُّ بِالسَّاحِلِ يَأْخُذْهُ عَدُوٌّ لِّي وَعَدُوٌّ لَّهُ وَأَلْقَيْتُ عَلَيْكَ مَحَبَّةً مِّنِّي وَلِتُصْنَعَ عَلَى عَيْنِي
20:40 "Behold! thy sister goeth forth and saith, 'shall I show you one who will nurse and rear the (child)?' So We brought thee back to thy mother, that her eye might be cooled and she should not grieve. Then thou didst slay a man, but We saved thee from trouble, and We tried thee in various ways. Then didst thou tarry a number of years with the people of Midian. Then didst thou come hither as ordained, O Moses! إِذْ تَمْشِي أُخْتُكَ فَتَقُولُ هَلْ أَدُلُّكُمْ عَلَى مَن يَكْفُلُهُ فَرَجَعْنَاكَ إِلَى أُمِّكَ كَيْ تَقَرَّ عَيْنُهَا وَلَا تَحْزَنَ وَقَتَلْتَ نَفْسًا فَنَجَّيْنَاكَ مِنَ الْغَمِّ وَفَتَنَّاكَ فُتُونًا فَلَبِثْتَ سِنِينَ فِي أَهْلِ مَدْيَنَ ثُمَّ جِئْتَ عَلَى قَدَرٍ يَا مُوسَى
Second occasion: 40:23-26 after Moses grow up and became a prophet:
40:23 Of old We sent Moses, with Our Signs and an authority manifest, وَلَقَدْ أَرْسَلْنَا مُوسَى بِآيَاتِنَا وَسُلْطَانٍ مُّبِينٍ
40:24 To Pharaoh, Haman, and Qarun; but they called (him)" a sorcerer telling lies!"...
إِلَى فِرْعَوْنَ وَهَامَانَ وَقَارُونَ فَقَالُوا سَاحِرٌ كَذَّابٌ
40:25 Now, when he came to them in Truth, from Us, they said, "Slay the sons of those who believe with him, and keep alive their females," but the plots of Unbelievers (end) in nothing but errors (and delusions)!...
فَلَمَّا جَاءهُم بِالْحَقِّ مِنْ عِندِنَا قَالُوا اقْتُلُوا أَبْنَاء الَّذِينَ آمَنُوا مَعَهُ وَاسْتَحْيُوا نِسَاءهُمْ وَمَا كَيْدُ الْكَافِرِينَ إِلَّا فِي ضَلَالٍ
40:26 Said Pharaoh: "Leave me to slay Moses; and let him call on his Lord! What I fear is lest he should change your religion, or lest he should cause mischief to appear in the land!"
وَقَالَ فِرْعَوْنُ ذَرُونِي أَقْتُلْ مُوسَى وَلْيَدْعُ رَبَّهُ إِنِّي أَخَافُ أَن يُبَدِّلَ دِينَكُمْ أَوْ أَن يُظْهِرَ فِي الْأَرْضِ الْفَسَادَ