private void button3_Click(object sender, EventArgs e) { if (LoadedQuestion != null && Clean(TB_freq.Text) != String.Empty && Clean(TB_weight.Text) != String.Empty) { int UserWeight = Int32.Parse(Clean(TB_weight.Text)); int UserFreq = Int32.Parse(Clean(TB_freq.Text)); WeightFreq UserWF = new WeightFreq(UserWeight); UserWF.SetFrequency(UserFreq); LoadedQuestion.AddWeightFreq(UserWF, false); RefreshQDataView(); } else { MessageBox.Show("Invalid input data!\nEither no question data or text field has non-allowed characters.", "Error"); } }