每当用户尝试输入不在该范围内的数字时,[0, 24]
它应该显示一条错误消息。我接受浮点数的代码如下。如何修改它以添加范围验证?
private void h(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs e)
{
try
{
float time = float.Parse(hours.Text);
}
catch
{
label2.Text = "enter proper value ";
hours.Text = " ";
}
}