KB Home (KBH) - Get Report may have posted a loss in the second quarter, but -- at least according to the company -- happier days may be on the horizon.

Even though KB Home missed expectations, it managed to narrow its loss to $78.4 million, or $1.03 per share. Analysts expected a loss of 72 cents. This compares with a loss of $255.9 million, or $3.30 per share, in the year-ago period.

Revenue fell 40% to $384.5 million, beating Wall Street forecasts of $337.6 million.

"Although key economic indicators remain mixed, we are beginning to see signs that some negative housing market trends may be moderating at both the local and national levels," Chief Executive Jeffrey Mezger said in a statement.

The home builder said new home orders climbed 59% from the first quarter and the number of buyers backing out of contracts dropped.

Similarly, home builder


(LEN) - Get Report

, also found some sunshine in its loss of $125.2 million, or 76 cents a share.

The company noted that its cancellation rate shrunk to 15% from 22% in the year-ago period, and it posted a 47% increase in sales of completed homes and a 63% jump in orders from the first quarter.

Revenue fell 21% to $891.9 million, but it beat analysts' expectations of $597.5 million.

Copyright 2009 TheStreet.com Inc. All rights reserved. This material may not be published, broadcast, rewritten, or redistributed. AP contributed to this report.