A method of controlling opening and closing of a valve of an internal combustion engine by combining an electromagnetic force produced by an electromagnet and an elastic force produced by an elastic member, the control method comprising:supplying an attracting current to the electromagnet when the valve is to be attracted to the electromagnet; detecting whether there is a step out of the valve fro