Using density functional theory and generalized gradient approximation for exchange and correlation, we present theoretical analysis of the electronic structure of recently synthesized graphyne and its boron nitride analog (labeled as BN-yne). The former is composed of hexagonal carbon rings joined by C-chains, while the latter is composed of hexagonal BN rings joined by C-chains. We have explored the nature of bonding and energy band structure of these unique systems characterized by sp and sp(2) bonding. Both graphyne and BN-yne are found to be direct bandgap semiconductors. The bandgap can be modulated by changing the size of hexagonal ring and the length of carbon chain, providing more flexibilities of energy band engineering for device applications. The present study sheds theoretical insight on better understanding of the properties of the novel carbon-based 2D structures beyond the graphene sheet.