Kpoof
New member
- Joined
- Jan 10, 2022
- Messages
- 3
- Programming Experience
- Beginner
Hello,
I have been all over the internet and booted by StackOverflow for trying to solve this but I cannot seem to turn a string into an integer using TryParse or Parse. I am trying to create a simple unique calculator for work that will calculate numbers entered on click. variable "uc2x4" is the string i wish to turn into an int. Thanks for any help
I have been all over the internet and booted by StackOverflow for trying to solve this but I cannot seem to turn a string into an integer using TryParse or Parse. I am trying to create a simple unique calculator for work that will calculate numbers entered on click. variable "uc2x4" is the string i wish to turn into an int. Thanks for any help
C#:
namespace Test
{
public partial class Form1 : Form
{
string uc2x4 = "0";
int x = 0;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text != "0" && textBox1.Text != null)
{
uc2x4 = textBox1.Text;
int x = Int32.Parse(uc2x4);
}
else
{
label1.Text = "no";
}
}
private void button1_Click(object sender, EventArgs e)
{
label2.Text = x * 2;
}
}
}
Last edited by a moderator: