why does the label doesn’t exist in my code? im using .net c#
private void Button1_Click(object sender, EventArgs e)
{
int unitCost = 0;
int quantity = 0;
if (int.TryParse(TextBox2.Text, out unitCost) && int.TryParse(TextBox3.Text, out quantity))
{
if (unitCost == 300)
{
Label10.Text = "$300";
}
else if (unitCost == 500)
{
Label10.Text = "$500";
}
else if (unitCost == 200)
{
Label10.Text = "$200";
}
else if (unitCost == 100)
{
Label10.Text = "$100";
}
int totalCost = unitCost * quantity;
Label11.Text = totalCost.ToString();
}
}
private void Button2_Click(object sender, EventArgs e)
{
Label10.Text = "";
Label11.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
MessageBox.Show("Purchase successful!");
}
10 Replies
did you create those controls and is this WinForms?
By default when a control is generated, it's name is in Camel case
label10, textBox2, etc...
Yes
for both?
can you show the form's designer
Not pascalcase but camelcase
I turned just turned off my pc 😭
Ill show you later but thanks tho
aight
eh, i typo'd sry lol
I didn't realize i typed the wrong word lol
I give 10:1 odds on they're not working with the form code behind.
did you make sure that youve entered the correct control name?