IsNumeric









How do I use Is Numeric
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Form1.cs Copy
58   public void Button1_Click(System.Object sender, System.EventArgs e)
59   {
60    int a = default(int);
61    decimal b = new decimal();
62
63    if (Information.IsNumeric(TextBox3.Text))
64    {
65     if (int.Parse(TextBox3.Text) <= 20 )
66     {
67      a = (int) ((double.Parse(TextBox3.Text) * 100) / 20);
68      TextBox4.Text = a.ToString();
69      b = (decimal) (a * 0.1);
70      TextBox5.Text = b.ToString();
71     }
72     else
73     {
74      MessageBox.Show("Please Enter value equal to 20 and below!");
75     }
76    }
77    if (Information.IsNumeric(TextBox6.Text))
78    {
79
80     if (int.Parse(TextBox6.Text) <= 50 )
81     {
82      int c = default(int);
83      decimal d = new decimal();
84      c = (int) ((double.Parse(TextBox6.Text) * 100) / 50);
85      TextBox7.Text = c.ToString();
86      d = (decimal) (c * 0.1);
87      TextBox8.Text = d.ToString();
88
89     }
90     else
91     {
92      MessageBox.Show("Please Enter value equal to 50 and below!");
93
94
95     }
96    }
97
98    if (Information.IsNumeric(TextBox9.Text))
99    {
100     if (int.Parse(TextBox9.Text) <= 50 )
101     {
102      int g = default(int);
103      decimal f = new decimal();
104      g = (int) ((double.Parse(TextBox9.Text) * 100) / 50);
105      TextBox10.Text = g.ToString();
106      f = (decimal) (g * 0.2);
107      TextBox11.Text = f.ToString();
108
109     }
110     else
111     {
112      MessageBox.Show("Please Enter value equal to 50 and below!");
113
114
115     }
116    }
117    if (Information.IsNumeric(TextBox12.Text))
118    {
119     if (int.Parse(TextBox12.Text) <= 100 )
120     {
121      int g = default(int);
122      decimal f = new decimal();
123      g = (int) ((double.Parse(TextBox12.Text) * 100) / 100);
124      TextBox13.Text = g.ToString();
125      f = (decimal) (g * 0.3);
126      TextBox14.Text = f.ToString();
127
128     }
129     else
130     {
131      MessageBox.Show("Please Enter value equal to 100 and below!");
132
133
134     }
135    }
136
137    if (Information.IsNumeric(TextBox15.Text))
138    {
139     if (int.Parse(TextBox15.Text) <= 100 )
140     {
141      int j = default(int);
142      decimal f1 = new decimal();
143      j = (int) ((double.Parse(TextBox15.Text) * 100) / 100);
144      TextBox16.Text = j.ToString();
145      f1 = (decimal) (j * 0.3);
146      TextBox17.Text = f1.ToString();
147
148     }
149     else
150     {
151      MessageBox.Show("Please Enter value equal to 100 and below!");
152
153
154     }
155    }
156
157    decimal adal = new decimal();
158    adal = (decimal) (Conversion.Val(TextBox5.Text) + Conversion.Val(TextBox8.Text) + Conversion.Val(TextBox11.Text) + Conversion.Val(TextBox14.Text) + Conversion.Val(TextBox17.Text));
159
160    TextBox18.Text = adal.ToString();
161
162    if (Conversion.Val(TextBox18.Text) <= 74)
163    {
164
165     TextBox19.Text = "Failed";
166     TextBox19.ForeColor = Color.Red;
167    }
168    else
169    {
170     TextBox19.Text = "Passed";
171     TextBox19.ForeColor = Color.Black;
172
173
174    }
175
176
177   }

IsNumeric 141 lượt xem

Gõ tìm kiếm nhanh...