public void AddToItems(object sender, System.EventArgs e) { string items = Interaction.InputBox("Enter total items", "", "1", 100, 100); int a = 0; if (int.TryParse(items, out a)) { if (IsUnitLeftEnough(int.Parse(pos.SetUnitLeft.Text), int.Parse(items))) { pos.InsertItem(pos.SetCode.Text, int.Parse(items)); pos.AddItemsData(); } else { MessageBox.Show("Unit left not enough"); } } else { MessageBox.Show("Please enter a number"); } }