Ternary alloy CdZnO and MgZnO thin films were obtained by radio frequency-assisted (RF) molecular beam epitaxy (MBE). The films were characterized by photoluminescence, X-ray diffraction, UV-visible absorption, scanning electron microscopy and Hall coefficient measurement. When Cadmium or Magnesium was co-deposited with Zinc under Oxygen ambient, the bandgap of ZnO based samples were tuned in the range of 2.25-4.76eV which were confirmed by band edge luminescence and Tauc plot. To overcome the shortage of unstable p-type ZnO semiconductor and simplify the complexity fabrication procedure for optical applications, a semiconductor-metal-semiconductor (MSM) device structure was developed. Electrically driven random laser devices based on the MSM structure were demonstrated by both experimental and simulation results, suggesting the ZnO material with excitonic properties under room temperature a potential competitive candidate in UV optical applications.