Using a trimmed rectangular B-Spline surface to fill an n-sided hole is a much desired operation in computer aided design (CAD), but few papers have addressed this issue. Based on an energy-minimization or variational B-Spline technique, the paper presents the technique of using one single trimmed rectangular B-Spline surface to fill an n-sided hole. The method is efficient and robust, and takes a fraction of a second to fill n-sided holes with high-quality waterproof B-Spline surfaces under complex constraints. As the foundation of filling n-sided holes, the paper also presents the framework and addresses the key issues on variational B-Spline technique. Without any precalculation, the variational B-Spline technique discussed in this paper can solve virtually any B-Spline surface with up to 20,000 control points in real time, which is much more efficient and powerful than previous work in the variational B-Spline field. Moreover, the result is accurate and satisfies CAD systems' high-precision requirements.