C
C#3mo ago
cl_quandale

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!"); }
No description
10 Replies
SG97
SG973mo ago
did you create those controls and is this WinForms?
TheRanger
TheRanger3mo ago
By default when a control is generated, it's name is in Camel case label10, textBox2, etc...
cl_quandale
cl_quandale3mo ago
Yes
SG97
SG973mo ago
for both? can you show the form's designer
Buddy
Buddy3mo ago
Not pascalcase but camelcase
cl_quandale
cl_quandale3mo ago
I turned just turned off my pc 😭 Ill show you later but thanks tho
SG97
SG973mo ago
aight
TheRanger
TheRanger3mo ago
eh, i typo'd sry lol I didn't realize i typed the wrong word lol
Mayor McCheese
Mayor McCheese3mo ago
I give 10:1 odds on they're not working with the form code behind.
PracticeMedicine
did you make sure that youve entered the correct control name?
Want results from more Discord servers?
Add your server
More Posts