Adaptive slope compensation programmable by input voltage of power converter

A method for controlling a power converter and the power converter are provided. The method includes the following steps. A switching signal coupled to switch a transformer for regulating the output of the power converter is generated in accordance with a feedback signal and a ramp signal. The ramp signal is generated in accordance with a switching current signal and a slope compensation signal. The slope compensation signal is generated in response to an input voltage signal. The input voltage signal is generated in response to the level of the input voltage of the power converter. The feedback signal is generated in accordance with the output of the power converter, and the switching current signal is correlated with a switching current of the transformer.