if (!char.TryParse(txtCustomerName.Text, out charCustomerName)) //try to read in Layers from TextBox
{
MessageBox.Show("Customer Name must be entered.", "Invalid Customer Name");
return;
}
if (!Decimal.TryParse(txtAmountOwed.Text, out decAmountOwed)) //try to read in Layers from TextBox
{
MessageBox.Show("Amount Owed must be entered without dollar signs or commas.", "Invalid Amount Owed");
return;
}
if (!int.TryParse(txtDaysOverdue.Text, out intDaysOverdue)) //try to read in Layers from TextBox
{
MessageBox.Show("Days Overdue must be entered as a whole number.", "Invalid Days Overdue");
return;
}
When I run the program, it tells me the customer name must be entered even though I entered it. How do I change that?
char.TryParse? That will try to parse the String (text) into achartype, which is a single character.!string.IsNullOrEmpty(txtCustomerName.Text)?