Jump to content

 

All the .Text are underlined

  	decimal mySalesAmount;
            decimal myTaxAmount;
            decimal myTotalAmount;
            mySalesAmount = decimal.Parse(mySalesAmount.Text);
            myTaxAmount = decimal.Parse(myTaxAmount.Text);
            myTotalAmount = mySalesAmount * myTaxAmount;
            myTotalAmount.Text = myTotalAmount.ToString("c");

These are all lined up btw in Visual Studio. Basically, mySalesAmount is what a user paid for say a fast food bill, then the myTaxAmount is what the Tax of said user is. I then I need to multiply these to get the Tax in which the user paid, which is going to be displayed in myTotalAmount. I understand that it says myTotalAmount, I then need to add the myTotalAmount and the mySalesAmount to get the REAL myTotalAmount, I changed the GUI up a bit inbetween code to make it more user friendly. Keep in my this is one of my first C# codes, talk to me like a 6 year old.

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to comment
https://linustechtips.com/topic/547482-why-will-this-c-code-not-work/
Share on other sites

Link to post
Share on other sites

Hey man, I would love to help you but am really confused on what you are trying to accomplish on lines: 

 mySalesAmount = decimal.Parse(mySalesAmount.Text);
 myTaxAmount = decimal.Parse(myTaxAmount.Text);

I can tell you the reason its red is the decimal data type does not contain a "Text" property or field, but not sure how to help you since it appears you are just attempting to set a variable to itself here. 

 

Even if this did execute it would be equivalent of a = 1 then a = a.

Link to post
Share on other sites

2 minutes ago, andrew_on_tech said:

Hey man, I would love to help you but am really confused on what you are trying to accomplish on lines: 


 mySalesAmount = decimal.Parse(mySalesAmount.Text);
 myTaxAmount = decimal.Parse(myTaxAmount.Text);

I can tell you the reason its red is the decimal data type does not contain a "Text" property or field, but not sure how to help you since it appears you are just attempting to set a variable to itself here. 

 

I think he's trying to parse in the values entered into the textbox 

i5 2400 | ASUS RTX 4090 TUF OC | Seasonic 1200W Prime Gold | WD Green 120gb | WD Blue 1tb | some ram | a random case

 

Link to post
Share on other sites

1 minute ago, andrew_on_tech said:

Hey man, I would love to help you but am really confused on what you are trying to accomplish on lines: 


 mySalesAmount = decimal.Parse(mySalesAmount.Text);
 myTaxAmount = decimal.Parse(myTaxAmount.Text);

I can tell you the reason its red is the decimal data type does not contain a "Text" property or field, but not sure how to help you since it appears you are just attempting to set a variable to itself here. 

 

Even if this did execute it would be equivalent of a = 1 then a = a.

To get the sales amount and tax amount.

 

Though I may be doing it all wrong. Basically, my goal is to put in a number and a tax amount then calculate what the tax will be and what the total amount would be.

 

I have all my buttons in there, so far I only have the GUI created and the Clear button which basically just clears all the text boxes.

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

Just now, andrew_on_tech said:

Ah, do you know what he is using for UI, windows forms, WPF, some other libs? 

Visual Studio 2012 Express? Or am I thinking something else?

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

Just now, andrew_on_tech said:

Ah, do you know what he is using for UI, windows forms, WPF, some other libs? 

 

Sadly no, but from the codes and the use case description. It seemed like he was using a textbox

i5 2400 | ASUS RTX 4090 TUF OC | Seasonic 1200W Prime Gold | WD Green 120gb | WD Blue 1tb | some ram | a random case

 

Link to post
Share on other sites

Just now, Pohernori said:

 

Sadly no, but from the codes and the use case description. It seemed like he was using a textbox

 

2 minutes ago, andrew_on_tech said:

Ah, do you know what he is using for UI, windows forms, WPF, some other libs? 

Ohh yeah I am using Text Boxes.

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

Just now, DarkBlade2117 said:

Visual Studio 2012 Express? Or am I thinking something else?

So visual studio is your IDE, or editing environment for future reference. 

Just now, DarkBlade2117 said:

 

Ohh yeah I am using Text Boxes.

Ok so textbox class is part of the Windows Forms libraries. Can you post your Entire .CS file contents here. I have some ideas on what may be your issues but I need to see more to know. 

Link to post
Share on other sites

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

I think I get what's your problem

 

The variable names you've chosen for the variables that you've created looks to be conflicting with the textbox name. 

You're using mySalesAmount.Text to parse in to mySalesAmount . The names of your textbox and viarable are conflicting. 

 

Use a different name for your textbox or variable. 

 

i5 2400 | ASUS RTX 4090 TUF OC | Seasonic 1200W Prime Gold | WD Green 120gb | WD Blue 1tb | some ram | a random case

 

Link to post
Share on other sites


 

3 minutes ago, DarkBlade2117 said:

 

6 minutes ago, andrew_on_tech said:

So visual studio is your IDE, or editing environment for future reference. 

Ok so textbox class is part of the Windows Forms libraries. Can you post your Entire .CS file contents here. I have some ideas on what may be your issues but I need to see more to know. 

 

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

2 minutes ago, Pohernori said:

I think I get what's your problem

 

The variable names you've chosen for the variables that you've created looks to be conflicting with the textbox name. 

You're using mySalesAmount.Text to parse in to mySalesAmount . The names of your textbox and viarable are conflicting. 

 

Use a different name for your textbox or variable. 

 

That would be a problem :)

Link to post
Share on other sites

7 minutes ago, Pohernori said:

I think I get what's your problem

 

The variable names you've chosen for the variables that you've created looks to be conflicting with the textbox name. 

You're using mySalesAmount.Text to parse in to mySalesAmount . The names of your textbox and viarable are conflicting. 

 

Use a different name for your textbox or variable. 

 

Wait.. Like I said, very new to C# and apparently we were supposed to start out with console commands ( though never happened ) so this whole GUI thing is confusing.

What variable? I know the textbox name though..

Basically, what I am trying to do is take say I type like 63 into the mySalesAmount textbox, I want to be able to multiple that by whatever is entered into the myTaxAmount , say it be 6.25 for example, I then want that to be entered into the myTotalAmount Textbox. Total Amount will be changed to Tax Charged and then I want to be able to take the mySalesAmount ( 63 ) + the myTaxAmount for 6.25% * 63 = ( Whatever ) is displayed in the new myTotalAmount

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

8 minutes ago, DarkBlade2117 said:

Rename one of your variables. They are too similar and VS in confused as to what you are referring to.

 

so for the textbox name. Maybe mySalesAmountText.

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to post
Share on other sites

Just now, DarkBlade2117 said:

Wait.. Like I said, very new to C# and apparently we were supposed to start out with console commands so this whole GUI thing is confusing.

Basically, what I am trying to do is take say I type like 63 into the mySalesAmount textbox, I want to be able to multiple that by whatever is entered into the myTaxAmount , say it be 6.25 for example, I then want that to be entered into the myTotalAmount Textbox. Total Amount will be changed to Tax Charged and then I want to be able to take the mySalesAmount ( 63 ) + the myTaxAmount for 6.25% * 63 = ( Whatever ) is displayed in the new myTotalAmount

I'll tell you what, if you can tell me whether you want a console application or a GUI application I can do a quick screen capture and you can watch me do it, that way you can see exactly what the process should be.

Link to post
Share on other sites

1 minute ago, andrew_on_tech said:

I'll tell you what, if you can tell me whether you want a console application or a GUI application I can do a quick screen capture and you can watch me do it, that way you can see exactly what the process should be.

I need a GUI application

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

3 minutes ago, DarkBlade2117 said:

Wait.. Like I said, very new to C# and apparently we were supposed to start out with console commands ( though never happened ) so this whole GUI thing is confusing.

What variable? I know the textbox name though..

Basically, what I am trying to do is take say I type like 63 into the mySalesAmount textbox, I want to be able to multiple that by whatever is entered into the myTaxAmount , say it be 6.25 for example, I then want that to be entered into the myTotalAmount Textbox. Total Amount will be changed to Tax Charged and then I want to be able to take the mySalesAmount ( 63 ) + the myTaxAmount for 6.25% * 63 = ( Whatever ) is displayed in the new myTotalAmount

 

You cannot use the same name for your variable and textbox, it will conflict. Rename either your textboxes or your variables. 

 

Variables are this: 

 

decimal mySalesAmount;
            decimal myTaxAmount;
            decimal myTotalAmount;

i5 2400 | ASUS RTX 4090 TUF OC | Seasonic 1200W Prime Gold | WD Green 120gb | WD Blue 1tb | some ram | a random case

 

Link to post
Share on other sites

17 minutes ago, Pohernori said:

 

You cannot use the same name for your variable and textbox, it will conflict. Rename either your textboxes or your variables. 

 

Variables are this: 

 


decimal mySalesAmount;
            decimal myTaxAmount;
            decimal myTotalAmount;

 

19 minutes ago, andrew_on_tech said:

I'll tell you what, if you can tell me whether you want a console application or a GUI application I can do a quick screen capture and you can watch me do it, that way you can see exactly what the process should be.

Ohhh so I got it

 decimal mySalesAmount;
            decimal myTaxAmount;
            decimal myTaxPaid;
            mySalesAmount = decimal.Parse(mySalesAmountText.Text);
            myTaxAmount = decimal.Parse(myTaxPercentText.Text);
            myTaxPaid = mySalesAmount * myTaxAmount;
            myTaxPaidText.Text = myTaxPaid.ToString("c");  

So now my problem is the bottom right is underlined, myTaxPaid.ToString ect, that is meant to display the end calculation in the myTaxPaid text box. I then need to take that number in the myTaxPaidText textbox + the mySalesAmountText textbox and to display in the myTotalAmountText textbox 

 

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

20 minutes ago, DarkBlade2117 said:

 

Ohhh so I got it


 decimal mySalesAmount;
            decimal myTaxAmount;
            decimal myTaxPaid;
            mySalesAmount = decimal.Parse(mySalesAmountText.Text);
            myTaxAmount = decimal.Parse(myTaxPercentText.Text);
            myTaxPaid = mySalesAmount * myTaxAmount;
            myTaxPaidText.Text = myTaxPaid.ToString("c");  

So now my problem is the bottom right is underlined, myTaxPaid.ToString ect, that is meant to display the end calculation in the myTaxPaid text box. I then need to take that number in the myTaxPaidText textbox + the mySalesAmountText textbox and to display in the myTotalAmountText textbox 

 

Did my video clear up your questions? 

Link to post
Share on other sites

25 minutes ago, andrew_on_tech said:

Did my video clear up your questions? 

:o Yes it did, So many people try and tell me to go out and figure it out on my own, and yeah maybe at one point I should though for learning showing me how to do it from start will show me how I can figure out or attempt to do it by myself in the future. Thanks so much

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

Just now, DarkBlade2117 said:

:o Yes it did, So many people try and tell me to go out and figure it out on my own, and yeah maybe at one point I should though for learning showing me how to do it from start will show me how I can figure out or attempt to do it by myself in the future. Thanks so much

I agree, being a self taught professional I went through the same thing. This may have inspired me to broaden my YouTube channel to include beginner programming tutorials, do you think you/others would like to see more videos like what I made for you?

Link to post
Share on other sites

Just now, andrew_on_tech said:

I agree, being a self taught professional I went through the same thing. This may have inspired me to broaden my YouTube channel to include beginner programming tutorials, do you think you/others would like to see more videos like what I made for you?

I would love it, Going to have some hard times in this class. This program which I've been trying to figure out for 5 hours is only 33% of the assignment itself. I also need to create a Car Cost Comparison program in which I obviously compare two cars.

Purchase Price

Annual Repair Cost

Annual Insurance Cost

First calculation being 1 year total fuel cost and

then the second one being 5 years for total of all cost including Purchase Price, 5 year annual fuel cost, 5 years of repairs and 5 years of insurance all in one calculation... http://imgur.com/a/I68NF basically..

Maybe it wouldn't be so hard if I weren't taking 5 other classes and already get a few hours of homework from them also and being on a time frame can be troublesome.

I'll come on tomorrow if I need any help with this at all, hopefully I can get through it.

 

 

i7-6700k  Cooling: Deepcool Captain 240EX White GPU: GTX 1080Ti EVGA FTW3 Mobo: AsRock Z170 Extreme4 Case: Phanteks P400s TG Special Black/White PSU: EVGA 850w GQ Ram: 64GB (3200Mhz 16x4 Corsair Vengeance RGB) Storage 1x 1TB Seagate Barracuda 240GBSandisk SSDPlus, 480GB OCZ Trion 150, 1TB Crucial NVMe
(Rest of Specs on Profile)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×