General diagnostic classification models (DCMs) can be used to capture individual students’ cognitive learning status. Moreover, DCMs for longitudinal data are appropriate to track students transition of cognitive elements. This study developed an effective Bayesian posterior approximation method called variational Bayesian (VB) inference method for hidden Markov type longitudinal general DCMs. Simulation study indicated the proposed algorithm could satisfactorily recover true parameters. Comparative study of the VB and previously developed Markov chain Monte Carlo (MCMC) methods was conducted in real data example. The result revealed that the VB method provided similar parameter estimates to the MCMC with faster estimation time.