Electronic structures of MoS2 and MoSe2 surfaces are investigated by first-principles electronic-structure calculations. The ultrasoft pseudopotential by Vanderbilt is used to perform band calculations with a plane-wave basis. Calculated band structures are consistent with recent calculations using other methods. Scanning-tunneling-microscopy (STM) images are calculated from the results of the band calculations, and it is found that bright spots in experimental STM images correspond to chalcogen atoms of the outermost layer. First-principles band calculations by linear combination of atomic orbitals (LCAO) are also performed. It is found that the LCAO method is not so accurate in expressing the electronic properties of conduction bands of molybdenum dichalcogenides. The calculated band structures near the Fermi level show large dispersions along the direction perpendicular to the surface, which explains indirectly the fact that, in spite of the weak van der Waals interlayer interaction, moiré patterns are observed in the STM images of a MoSe2 surface grown on a MoS2 substrate. The appearance of the moiré patterns is more directly demonstrated by performing a band calculation of a MoSe2 surface with an irregular structure modeling the MoSe2/MoS2 surface. It is found that the influence of the substrate on the outermost layer propagating through several Se-Mo-Se sandwiches is sufficiently large to reproduce the moiré patterns. However, the simulated image cannot explain some features of the experimental moiré patterns, which suggests that relaxation of atomic structures is also necessary to explain the moiré patterns.