Cardiovascular diseases are the leading cause of death in recent decades, which are increasing due to changes in people's lifestyles. Their treatment has high costs and a long treatment process. Therefore, predicting such diseases can provide care, and prevention services and treatment programs can be very useful to increase the quality of life and reduce the cost of treatment and the risk of death for patients. Various artificial neural network (ANN) techniques and machine learning (ML) algorithms can be used as efficient and reliable methods to automatically analyze and detect the hidden patterns of patient medical records data collected through medical examinations related to cardiovascular diseases. In this paper, the multilayer perceptron (MLP) neural network is employed as a supervised learning approach to detect cardiovascular diseases. Moreover, we propose a modified version of moth-flame optimization algorithm named as MMFO which is used to achieve the optimal values of weights and biases in the MLP to speed-up the training process and provide more accurate predictions. The effectiveness of the proposed method is assessed according to performing extensive experiments on three cardiovascular disease datasets from the UCI repository, and its performance is compared with different state-of-the-art classification approaches. The results reveal that the proposed method performs better than other models in terms of all medical datasets.