The buoyancy-driven magnetoconvection in the cross section of an infinitely long vertical square duct is investigated numerically using the CFX code package. The implementation of a magnetohydrodynamic (MHD) problem in CFX is discussed, with particular reference to the Lorentz forces and the electric potential boundary conditions for arbitrary electrical conductivity of the walls. The method proposed is general and applies to arbitrary geometries with an arbitrary orientation of the magnetic field. Results for fully developed flow under various thermal boundary conditions are compared with asymptotic analytical solutions. The comparison shows that the asymptotic analysis is confirmed for highly conducting walls as high velocity jets occur at the side walls. For weakly conducting walls, the side layers become more conducting than the side walls, and strong electric currents flow within these layers parallel to the magnetic field. As a consequence, the velocity jets are suppressed, and the core solution is only corrected by the viscous forces near the wall. The implementation of MHD in CFX is achieved.