Hi all,
i am trying to convert words( i.e one,two,three....) to numbers(1,2,3....).Convert.ToInt32 or Parse did not work. Can anybody please guide me how can i achieve that.
Thanks a lot in advance.
Hi all,
i am trying to convert words( i.e one,two,three....) to numbers(1,2,3....).Convert.ToInt32 or Parse did not work. Can anybody please guide me how can i achieve that.
Thanks a lot in advance.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Matthew CatheyPosted Sep 3, 2008, 6:26 PM
Create an int variable in the main form class. When the user enters/selects the number option (One, Two, Three, etc.) from the object (combo box, label, etc.) have that selection assign the corresponding number to the int variable. For example:
public partial class frmMain:Main
{
int intNumber;
//Using a combo box
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox1.Text)
{
case "One":
intNumber = 1;
break;
case "Two":
intNumber = 2;
break;
case "Three":
intNumber = 3;
break;
default:
break;
}
}
}