I'm doing a shopping program and found it on that same site. The answer to a problem I had, but I did not understand what the (Char)0
part would be, among others. I need to explain what this is.
private void preVenda_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar < '0' || e.KeyChar > '9') &&
e.KeyChar != ',' && e.KeyChar != '.' &&
e.KeyChar != (char)13 && e.KeyChar != (char)8)
{
e.KeyChar = (char)0;
}
else
{
if (e.KeyChar == '.' || e.KeyChar == ',')
{
if (!preVenda.Text.Contains(','))
{
e.KeyChar = ',';
}
else
{
e.KeyChar = (char)0;
}
}
}
}
Here is the image: