The של״ה הקודש points out that Parshat Balak is teaching the idea that מעז יצא מתוק, "Out of the strong, came something sweet." This was a riddle connected with Samson and referred to honey that comes from bees, where one needs to be strong to get to it, but when he does, he is left with sweet honey.
The Midrash says that Hashem tells Bilaam, לא מדובשך ולא מעוקצך, not your honey and not your sting. Again, there is the analogy of a difficulty followed by something positive.
There is a third quote from the Midrash that says that Achashveirosh's removal of his ring and giving it to Haman, did more to encourage Teshuva than all of the words of the prophets combined.
We are to be reminded that it is often necessary to go through difficulties in order to appreciate the good that follows. When Hashem disciplines us, it is for our benefit. This is also the idea of turning the curses into blessings. We must have the faith to realize that all that Hashem does is for our good. Shabbat Shalom