The virtual-casing principle is used in plasma physics to convert a Biot–Savart integration over a current distribution into a surface integral over a surface that encloses the current. In many circumstances, use of virtual casing can significantly speed up the computation of magnetic fields. In this paper, a virtual-casing principle is derived for a general vector field with arbitrary divergence and curl. This form of the virtual-casing principle is thus applicable to both magnetostatic fields and electrostatic fields. The result is then related to Helmholtz's theorem.