Does this work for you?
private void button8_Click(object sender, EventArgs e)
{
string strInsertBefore = "<a>";
string strInsertAfter = "</a>";
string text = textBox4.Text.Substring(textBox4.SelectionStart, textBox4.SelectionLength);
text = strInsertBefore + text + strInsertAfter;
MessageBox.Show(text);
}