using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ScratchBook { public partial class Form1 : Form { public Form1() { InitializeComponent(); TextBox txtQuantity = new TextBox(); TextBox txtPrice = new TextBox(); ErrorProvider ep1 = new ErrorProvider(); Label lblMessage = new Label(); Int32 intQuantity = 0; decimal decPrice = 0; try { intQuantity = Int32.Parse(txtQuantity.Text); try { decPrice = decimal.Parse(txtPrice.Text); } catch (Exception e) { ep1.SetError(txtPrice, "Invalid Value"); lblMessage.Text = "Invalid Price"; txtPrice.Focus(); } } catch (Exception e) { ep1.SetError(txtQuantity, "Invalid Value"); lblMessage.Text = "Invalid Quantity"; txtQuantity.Focus(); } } } }