i dont understand why its erroring, streamreader is red
I've been stuck on this for a while but I seriously don't know what to do, Total is supposed to show the total price but it's just stuck on total
52 Replies
this is what i have
The Total click handler simply returns the button and doesn't call its click event
Is calculateTotal_Click tied to an event? Typycally you want event handlers to be void as you're not meant to call events handlers manually or raise them to get a value
i dont think so, all i have it tied to this click to calculate total
If you want to clean it up, you would have one void event handler but the button click that only calls a decimal method
That other method gets the input from the form, does the calculations and returns the result. The event handler takes the result and displays it
Or keep the getting of input in the event handler and pass them as parameters to the calculation method so that one becomes independent of the front-end (form)
i have it like this
So that method handles the click, the other just does the calculation, not taking a sender or eventargs
uhhh this is my code
i feel i need to type something in total_click
You can remove that one entirely
okay i took it off, but how would i make calculateTotal show me the answer? total still isnt changing (sorry im a bit learning disabled)
You commented out the line that sets the label text
but .Text isn't working, thats why i commented it out
total is a decimal variable
You need to reference your label
The line right above it
Same principle
.. oh
huh
You can also remove
total = total
yeah idk what i was doing with that
i think im getting closer
Coding is an iterative process after all 🙂
but im still trying to figure out how to get totalLabel.Text to work still im getting lil frustrated lol
im almost there
What line do you have now to set it?
Maybe it's not the right label
Try putting a breakpoint to see if the method runs
its like this now
And what's the error?
You shouldn't be able to run the app if there are errors
The name 'totalLabel' does not exist in the current context
If you select Yes on the prompt when running it, it's running the last successful build
What is the label called in the form?
legit i called it total
so it should be total.Text
wait
its not capital
However that means you have to rename either the label of variable to avoid a conflict
IT WASNT CAPITAL I DIDNT REALIZE I CAPITALIZED IT LMAO
totalLabel would be an appropriate name for it following the naming scheme of the rest of the form
but now its being weird and not showing stuff from optional costs
hm
Variable names are case sensitive so you won't have a conflict with total and Total but you should avoid this as you can easily confuse which is which
yes
but its completely ignoring part of my code
Does it compile?
yeah
Put a breakpoint in the code that's supposed to run and see if it gets hit
just to save what i got
Which part is it ignoring?
opt
Put a breakpoint in it
got it!
the button isnt actually fully working
but
Judging by this screenshot it should run
^q^
it runs!
thank you so so so much
New issue, new stuff
StreamReader, File, SIZE, and index is all in red
probably missing namespace declarations and size has an incomplete type specifier
how would i fix that?
add the appropriate usings to the top of the file for those types
or use ctrl + . to bring up suggestions that will most likely suggest to add them to have it done for you
is there a reason you are putting this in your entrypoint for your forms app
Hey! Just saw this, it’s a console app
the first 3 lines of your Main entrypoint says otherwise?
I told it to do console… huh. Weird.