With a view to understanding the relationship between oxygen stoichiometry, oxygen vacancy ordering, electronic structure, and Tc in the YBa2Cu3Ox system, we calculated the electronic structure for x=6, 7, and 8 using the first-principles self-consistent pseudofunction method. All three of these crystals contain O vacancies in the yttrium plane. The two O sites in the basal plane are empty in YBa2Cu3O6 and occupied in YBa2Cu3O8. Only one of these sites is occupied in YBa2Cu3O7 (ordered vacancy model). After discussing the essential features of the bandstructure and valence charge distribution for x=6,7, and 8, we explore the consequences of a simple Bardeen-Cooper-Schrieffer (BCS) model which assumes that Tc depends only on the electronic density of states at the Fermi level N(EF). Using our calculated values of N(EF) for x=6, 7, and 8, and a simple interpolation scheme, we obtain estimates for N(EF) for intermediate values of x and for various degrees of oxygen-vacancy disorder at fixed values of x. We can account for at least half of the observed variation of Tc with oxygen stoichimetry in the range 6.5<x<7 using physically reasonable values of the BCS parameters. We can also account for experimental observations that the greater the degree of oxygen-vacancy ordering at a fixed value of x, the higher the value of Tc. Our analysis also provides estimates for Tc for x between 6 and 6.5, but these estimates would apply to the metallic, rather than the semiconducting phase. Our analysis for x between 7 and 8 suggests that it might be possible to enhance the value of Tc beyond present-day values by preparing samples for which the O content is as large as possible, and for which the O vacancies are ordered to the highest possible degree. © 1987 The American Physical Society.