The reactions of 2- or 4-cyanopyridinium salts with active methylene compounds such as dimethyl malonate, malononitrile, and cyclohexane-1,3-dione affording 2- or 4-(substituted methylene) pyridines are described. Similar reactions of 4-cyano-2-methylthiopyridinium and 4-cyano-2-methylthioquinolinium salts, both of which have two leaving groups, were readily prepared from 4-cyano-1-methyl-2(1H)-pyridone and 4-cyano-1-methyl-2(1H)-quinolone via 4-cyano-1-methyl-2(1H)-thiopyridone and 4-cyano-1-methyl-2(1H)-thioquinolone in two steps, proceeding at the 2- and/or 4-positions on the pyridine or quinoline rings.