Hi i work in windows form application viusal studio 2008
I have windows form have two labeles label 33, label 34
label 33 represent quantity required
label 34 represent quantity shipped
if (Convert.ToInt32(label33.Text) == 0 && Convert.ToInt32(label34.Text) == 0)
{
Sales.
SalesClass SalesClass3 = new Sales.SalesClass();SalesClass3.DeleteProcessThird(
"Data Source=192.168.1.3;Initial Catalog=ALTAWI Group-Live;User ID=admin;Password=3210;Connection Lifetime=3;Max Pool Size=3;Connection Timeout=30");}
problem when converting string to integer
it give me error excption
Input sring was not in correct formate
how to solve this problem
Michal HabalcikPosted May 20, 2015, 1:50 AM
if (int.TryParse(label33.Text, out lbl 33) && int.TryParse(label34.Text, out lbl 34))
{
Sales.SalesClass SalesClass3 = new Sales.SalesClass();
SalesClass3.DeleteProcessThird("Data Source=192.168.1.3;Initial Catalog=ALTAWI Group-Live;User ID=admin;Password=3210;Connection Lifetime=3;Max Pool Size=3;Connection Timeout=30");
}
ahmed saPosted May 20, 2015, 1:46 AM
Michal HabalcikPosted May 20, 2015, 1:36 AM
ahmed saPosted May 20, 2015, 1:11 AM
ahmed saPosted May 20, 2015, 1:05 AM
Nanhe SiddiquePosted May 20, 2015, 12:48 AM
int byConverting = Convert.ToInt32(s);But among of all I think the
TryParseis best.Vincent Maverick DuranoPosted May 19, 2015, 6:26 PM
int myValue =0;
if(int.TryParse(Label1.Text,out myValue))
{
//the rest of your code here
}