C# substring text of a textbox and datetime picker to a maskbox : I use to generate the permanent code with a button after I entered everything.
like so: 
     mskCodePer.Text = txtNom.Text.Substring(0, 3) +    txtPrenom.Text.Substring(0, 1) + dptNaisc.Text.Substring(8, 2) + dptNaisc.Text.Substring(4, 4) + dptNaisc.Text.Substring(2, 3);


But my teacher force me to do it in a way that it happens automatically as I type, but I don't understand how.... I tried to code into the textchanged event but each time I only get to type one letter, it crash and tells me the ArgumentOutOfRangeException has not been generated 