In my case, KeyDown didn't work. I added "KeyPreview = true;" at the next line of "InitializeComponent();" , now it works perfectly. Thanks for your tutorial, it helps a lot :)
Make sure to set KeyPreview = true. Also the backspace button's official name is "backSpaceButton" which I accidentally left both of those pieces out of the tutorial. If you have issues with keys, take a look at KeyPreview!
Great video. The only thing I could add to improve the Calculator is to make it so once you have your result you can press any number and it will reset the label.text if you press any number. That way you do not have to click Clear each time. I guess a simple way to do this would be to setup a bool and make it equal to true after you click equals. Then if that bool is equal to true you go into each number button and set the displaylabel to the corresponding number and afterwards setting the bool back to false. Not needed though. Thanks for the content. I'm not a fan of Windows Forms but I need to learn it and most of the guides on it are quite dated.
i am new to coding and i like the calculator so much thanks. a few que. thou 1. how can i let the numbers i type stay in the display cause i dont want them disappearing when i type operators. 2. what if i want my operation to have more than two nums. like 2+3-6+7+9 ....
Great video! did you test out the enter key on your keyboard? everything else worked great on my end, I did have to add "KeyPreview = true" for the keyboard input. But when I press enter it kinda shows random numbers, I did compare the code between yours and what I had and it looks the same I'm not sure why the enter key isn't working properly. But besides that everything else is great! Thanks so much.
I thought I did test that out but this is the second comment saying something like that. So maybe not? But you can find this code on GitHub and compare that way if you’d like!
@@ShaunHalverson Did some debugging. To recreate the issue, one needs to click with mouse and then start using keys (add 12 + 44 with mouse and then press Enter, it will jump blink 444 before showing final result for 12 + 444). In this case ActiveControl holds the last mouse-selected key and pressing Enter adds it to the displayLabel, even before trigerring switch case. Haven't found how to fix it.
any suggestion how to add factorials function to this current calculator you made? looked up on the web and there are dozens of ways to add factorial functions and too overwhelm about it. im extremely new to coding since i just got into it, remembering dozens of functions is hard enough let alone making a simple calc app.
Hi! Hey don't worry about being new, all of us were new at some point. If you want to add a factorials function, what you need to do is the following. So factorials work like... 4! = 4*3*2*1 right? Well let's think about it. If the user has 4 in the calculator then presses the factorial button (that you will be adding). You just want to convert that string to an integer and then figure out how many times to multiply right? So if the user enters 4 and then clicks the !, you would convert the 4 to an int. Then you would loop and each iteration of a loop you would have a different variable keep track of what to multiply by and subtract 1 each time. So that all in all, you are multiplying 4*3*2*1 inside of the loop at the end. Make sense?
Be sure to leave enough time to let people see what you did. @15:01, you put the output for the equals, but you went to fast, you can't see it to follow along. Take 1-2 seconds at least so we can pause. Otherwise, overall good video.
The decimal button isn't working for me. It does add it into the label, but it doesn't act as a decimal. Let's say I type [ 5.2 + 2 ] and that will be equal to 54, not 7.2... I've tried tinkering with the boolean statement and changing the num1, num2 and result to other data types, but that didn't change anything.
Hi, I copied the code for backspace. It did erase the number but when I enter a new number it didn't erase the number I removed. (for example I entered "12" but I wanted to change it to "13" it became "123" instead) I don't know what I'm doing wrong tho .
Hi Aisha, I just ran my code to see if I had this issue and unfortunately I could not reproduce it. Can you send your code or compare it to the stuff I have on github? I would be happy to take a look and try to help!
i believe it is because the 0 button is hovered on the application so when you press enter, it enters a 0. With that being said, the keydown method looks like it only covers numbers 1-9, and the operators (plus, minus, multiplication, and division). I don't think we made one for equals unless I missed it. The Github doesn't have the equals button programmed out either.
In my case, KeyDown didn't work. I added "KeyPreview = true;" at the next line of "InitializeComponent();" , now it works perfectly. Thanks for your tutorial, it helps a lot :)
Thank you! :) glad you got it figured out too, nice job!
Make sure to set KeyPreview = true. Also the backspace button's official name is "backSpaceButton" which I accidentally left both of those pieces out of the tutorial. If you have issues with keys, take a look at KeyPreview!
I'm your biggest fan! Keep up the good work!
Thanks :)
Great video.
The only thing I could add to improve the Calculator is to make it so once you have your result you can press any number and it will reset the label.text if you press any number. That way you do not have to click Clear each time.
I guess a simple way to do this would be to setup a bool and make it equal to true after you click equals.
Then if that bool is equal to true you go into each number button and set the displaylabel to the corresponding number and afterwards setting the bool back to false.
Not needed though.
Thanks for the content. I'm not a fan of Windows Forms but I need to learn it and most of the guides on it are quite dated.
i am new to coding and i like the calculator so much thanks. a few que. thou
1. how can i let the numbers i type stay in the display cause i dont want them disappearing when i type operators.
2. what if i want my operation to have more than two nums. like 2+3-6+7+9 ....
Cool Video Man, Keep It Up💪🔥💯. Respect 🤝
Great video! did you test out the enter key on your keyboard? everything else worked great on my end, I did have to add "KeyPreview = true" for the keyboard input. But when I press enter it kinda shows random numbers, I did compare the code between yours and what I had and it looks the same I'm not sure why the enter key isn't working properly. But besides that everything else is great! Thanks so much.
I thought I did test that out but this is the second comment saying something like that. So maybe not? But you can find this code on GitHub and compare that way if you’d like!
yeah same problem!
@@ShaunHalverson Did some debugging. To recreate the issue, one needs to click with mouse and then start using keys (add 12 + 44 with mouse and then press Enter, it will jump blink 444 before showing final result for 12 + 444). In this case ActiveControl holds the last mouse-selected key and pressing Enter adds it to the displayLabel, even before trigerring switch case.
Haven't found how to fix it.
Very nice video, it helped me a lot, ill sub to you, i hope you keep making tutorials on diffent kind of useful apps :)
Thank you for the subscription and I definitely will, thank you! :)
really good explanation, thank you for your time and effort
any suggestion how to add factorials function to this current calculator you made? looked up on the web and there are dozens of ways to add factorial functions and too overwhelm about it. im extremely new to coding since i just got into it, remembering dozens of functions is hard enough let alone making a simple calc app.
Hi! Hey don't worry about being new, all of us were new at some point. If you want to add a factorials function, what you need to do is the following.
So factorials work like...
4! = 4*3*2*1 right?
Well let's think about it. If the user has 4 in the calculator then presses the factorial button (that you will be adding). You just want to convert that string to an integer and then figure out how many times to multiply right? So if the user enters 4 and then clicks the !, you would convert the 4 to an int. Then you would loop and each iteration of a loop you would have a different variable keep track of what to multiply by and subtract 1 each time. So that all in all, you are multiplying 4*3*2*1 inside of the loop at the end. Make sense?
Hey! I'm pretty sure we need to put something else in the plusMinus method! Otherwise you can get numbers like "--------5" 😁
Check out what he did with the decimal point. You should have a good idea of how to solve that issue.
Check out what he did with the decimal point. You should have a good idea of how to solve that issue.
Be sure to leave enough time to let people see what you did. @15:01, you put the output for the equals, but you went to fast, you can't see it to follow along. Take 1-2 seconds at least so we can pause. Otherwise, overall good video.
Gotcha, thanks for the feedback I will incorporate it into my future videos!
thank you for you, that's kind of you
I have a small question. If I want to add more than two numbers at the same time how should I do it?
here is a hint num3.
The decimal button isn't working for me. It does add it into the label, but it doesn't act as a decimal. Let's say I type [ 5.2 + 2 ] and that will be equal to 54, not 7.2... I've tried tinkering with the boolean statement and changing the num1, num2 and result to other data types, but that didn't change anything.
I solved it.. In my country, a comma is used as a decimal point. So yeah.. I just changed the dots to commas and now it's working.
That's awesome! Good job figuring that out :)
@@Bljeki thnx bro had the same problem (Iam from Greece)
Hi, I copied the code for backspace. It did erase the number but when I enter a new number it didn't erase the number I removed. (for example I entered "12" but I wanted to change it to "13" it became "123" instead) I don't know what I'm doing wrong tho .
Hi Aisha, I just ran my code to see if I had this issue and unfortunately I could not reproduce it. Can you send your code or compare it to the stuff I have on github? I would be happy to take a look and try to help!
thank you
Thank you for watching!
hi, can help me write a c # code that allows sending emails to mailboxes hosted in exhcange
Yeah I hope to make a video about this soon!
When i press enter, i just get answer 0
Are you calling the right button method when you click enter?
@@ShaunHalverson I'm having the same problem, and yes, i've quadruplechecked. Did you ever find a solution? Or perhaps it worked for you?
i believe it is because the 0 button is hovered on the application so when you press enter, it enters a 0. With that being said, the keydown method looks like it only covers numbers 1-9, and the operators (plus, minus, multiplication, and division). I don't think we made one for equals unless I missed it. The Github doesn't have the equals button programmed out either.
POV: you don't know about the TableLayoutPanel...