This is what’s really driving Costco’s stock, Jim Cramer says

Forget about the company's quarterly results: Costco shares are up because of its switch from American Express to Visa, CNBC's Jim Cramer said Thursday.

"The credit card switch is going to be humongous, and that's why people are buying Costco," Cramer said on "Squawk on the Street." "This is the quarter we were saying goodbye to American Express and going to Visa."

Costco announced it had entered a long-term credit card deal with Visa last year, replacing long-time partner American Express. The Visa credit card, which goes into effect on June 20, would provide richer rewards to Costco members than the American Express card did, and it will serve as the company's membership card.

On Wednesday, Costco posted fiscal third-quarter earnings of $1.24 per share on revenue of $26.77 billion. Analysts polled by Reuters expected the firm to report earnings of $1.22 on revenue of $27.07 billion.

The company's stock rose nearly 3.6 percent, but remained about 7.3 percent lower for the year.

COST in 2016Source: FactSet

— Reuters contributed to this report.

Disclosure: Cramer's trust owned Costco stock when this story was published.