示例#1
0
        private void butValidate4_Click(object sender, EventArgs e)
        {
            try
            {
                int x = int.Parse(String4.Text, System.Globalization.NumberStyles.None);
                String4.Text = x.ToString();
            }

            catch (Exception)
            {
                MessageBox.Show("Enter only numbers");
                String4.Clear();
            }
        }
示例#2
0
        private void butValidateall_Click(object sender, EventArgs e)
        {
            string a = string1.Text;

            for (int i = 0; i <= a.Length; i++)
            {
                a = a.Replace("$", "");
                a = a.Replace("@", "");
                a = a.Replace("#", "");
                a = a.Replace("%", "");
                a = a.Replace("&", "");
                a = a.Replace("^", "");
                a = a.Replace("*", "");
            }
            outptstring1.Text = a;
            string b = String3.Text;

            if (b.StartsWith(" ") || b.StartsWith("$") || b.StartsWith("@") || b.StartsWith("%") || b.StartsWith("#"))
            {
                MessageBox.Show("The string3 can't start with a space or $ or @ or % or #");
                String3.Clear();
                String3.Focus();
            }
            string c = string2.Text;

            if (c.EndsWith(" ") || c.EndsWith("$") || c.EndsWith("@") || c.EndsWith("%") || c.EndsWith("#"))
            {
                MessageBox.Show("The string2 can't End with a space or $ or @ or % or #");
                string2.Clear();
                string2.Focus();
            }

            try
            {
                int x = int.Parse(String4.Text, System.Globalization.NumberStyles.None);
                String4.Text = x.ToString();
            }

            catch (Exception)
            {
                MessageBox.Show("Enter only numbers");
                String4.Clear();
            }
        }