In summary, by comprehensively exploring various optoelectronic properties of B-N analogues of C18, (BN)4C10 as potential candidates for nonlinear optical (NLO) materials in the visible light region was screened, and the regulation of optoelectronic properties by different numbers of C-N units in the molecular ring was pointed out. This research is expected to help chemists better understand the optical properties of molecules composed of B, C, and N atoms, and to provide a reference for rational synthesis of B-N doped carbon materials, such as carbon rings, carbon tubes, and carbon spheres, with excellent optoelectronic properties.