The IBM logo is displayed on the IBM building in Midtown Manhattan. (Mary Altaffer/AP)

IBM announced its financial results for the second quarter on Wednesday, and it's safe to say the company has had happier statements.

Year-over-year sales declined for the 21st consecutive quarter, off by more than 4 percent from analysts' forecasts. For the three-month period ending June 30, revenue was down 4.7 percent to $19.3 billion compared to a year ago.

The company did beat analysts’ projected profit expectations by 18 cents, but that was only because results got a boost from a tax gain, according to MarketWatch. Even then, profits fell 6.9 percent to $2.3 billion, or $2.48 per share, for the quarter compared with a year ago.

IBM, once a dominant computer hardware company, has struggled in the past decade as it has transitioned into Internet cloud services, artificial intelligence and cybersecurity. Still, company executives expressed optimism during a conference call with analysts, touting IBM's progress on its “strategic imperatives.” For instance, revenue from its cloud services business was $3.9 billion for the quarter, a 15 percent increase from the last year. Revenue from its analytics unit increased 4 percent to $5.1 billion.

“We continue to innovate,” Ginni Rometty, IBM’s chairman and chief executive, said in a company statement.

The company said revenue from such imperatives totaled $34.1 billion over the past 12 months, a gain of 11 percent over the previous 12-month period, representing 43 percent of IBM's revenue. But the increase was not enough to offset hits to other, more traditional parts of its business, such as business services.

The company has tried to mollify shareholders by using $5 billion over the past six months to pay dividends and buy back stock, diminishing its supply and making the shares that remain more valuable. That has failed to arrest a slide in prices. In March, the company's stock was trading as high as $181.95 per share. On Wednesday, it opened on the New York Stock Exchange at $150.02, a 17.5 percent decrease at a time when the stock markets have posted record highs.

The company said it continues to make investments in its future. IBM opened four cloud data centers across the country in the second quarter to help deal with the growing demand for Internet technology. It also partnered with Lightbend, a software company that helps build apps, and acquired Timetoact Group's XCC, a digital workspace hub.

The company is hoping its latest technology in cybersecurity will boost business, but the effects of that are not likely to be seen for a while. On Monday, the company announced a breakthrough in security technology it claims would allow businesses to encrypt customer data on a broad scale, keeping it from hackers looking to steal customer information. The mainframe system is called IBM Z and is able to run 12 billion transactions a day.

James Kisner, an analyst with the investment firm Jeffries, told CNBC on Wednesday that IBM was slow to move to cloud services and now faces stiff competition from more agile competitors.

“The company missed some opportunities,” he told CNBC. “If they had acquired Salesforce years ago, that might have been something they could do,” Kisner said on “Squawk Box.”