C# Calculator App Tutorial For Beginners and Intermediate Programmers | Visual Studio 2021 | Part 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 40

  • @MinhyungJungKOR
    @MinhyungJungKOR 2 ปีที่แล้ว +5

    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 :)

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว

      Thank you! :) glad you got it figured out too, nice job!

  • @ShaunHalverson
    @ShaunHalverson  2 ปีที่แล้ว +1

    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!

  • @Lunar-rb9um
    @Lunar-rb9um 3 ปีที่แล้ว +2

    I'm your biggest fan! Keep up the good work!

  • @bruce8217
    @bruce8217 2 ปีที่แล้ว

    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.

  • @zgetlife8029
    @zgetlife8029 2 ปีที่แล้ว +1

    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 ....

  • @sthempanza5074
    @sthempanza5074 2 ปีที่แล้ว

    Cool Video Man, Keep It Up💪🔥💯. Respect 🤝

  • @munam4680
    @munam4680 2 ปีที่แล้ว +1

    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.

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว +1

      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!

    • @hei4227
      @hei4227 2 ปีที่แล้ว

      yeah same problem!

    • @karlism.5604
      @karlism.5604 ปีที่แล้ว

      @@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.

  • @LeReachMonkey
    @LeReachMonkey 3 ปีที่แล้ว +1

    Very nice video, it helped me a lot, ill sub to you, i hope you keep making tutorials on diffent kind of useful apps :)

    • @ShaunHalverson
      @ShaunHalverson  3 ปีที่แล้ว +1

      Thank you for the subscription and I definitely will, thank you! :)

  • @ikidtech
    @ikidtech ปีที่แล้ว

    really good explanation, thank you for your time and effort

  • @d3adg147
    @d3adg147 2 ปีที่แล้ว +1

    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.

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว

      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?

  • @rubensilva4105
    @rubensilva4105 2 ปีที่แล้ว +1

    Hey! I'm pretty sure we need to put something else in the plusMinus method! Otherwise you can get numbers like "--------5" 😁

    • @bruce8217
      @bruce8217 2 ปีที่แล้ว

      Check out what he did with the decimal point. You should have a good idea of how to solve that issue.

    • @bruce8217
      @bruce8217 2 ปีที่แล้ว

      Check out what he did with the decimal point. You should have a good idea of how to solve that issue.

  • @shawnl5874
    @shawnl5874 2 ปีที่แล้ว +2

    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.

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว +1

      Gotcha, thanks for the feedback I will incorporate it into my future videos!

  • @belaidamar1138
    @belaidamar1138 3 ปีที่แล้ว +1

    thank you for you, that's kind of you

  • @rarespetrescu5344
    @rarespetrescu5344 2 ปีที่แล้ว +1

    I have a small question. If I want to add more than two numbers at the same time how should I do it?

    • @bruce8217
      @bruce8217 2 ปีที่แล้ว

      here is a hint num3.

  • @Bljeki
    @Bljeki 2 ปีที่แล้ว +1

    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.

    • @Bljeki
      @Bljeki 2 ปีที่แล้ว +2

      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.

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว +1

      That's awesome! Good job figuring that out :)

    • @hei4227
      @hei4227 2 ปีที่แล้ว

      @@Bljeki thnx bro had the same problem (Iam from Greece)

  • @aisha2991
    @aisha2991 2 ปีที่แล้ว

    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 .

    • @ShaunHalverson
      @ShaunHalverson  2 ปีที่แล้ว

      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!

  • @belaidamar1138
    @belaidamar1138 3 ปีที่แล้ว +1

    thank you

  • @belaidamar1138
    @belaidamar1138 3 ปีที่แล้ว

    hi, can help me write a c # code that allows sending emails to mailboxes hosted in exhcange

    • @ShaunHalverson
      @ShaunHalverson  3 ปีที่แล้ว

      Yeah I hope to make a video about this soon!

  • @veilie3649
    @veilie3649 3 ปีที่แล้ว

    When i press enter, i just get answer 0

    • @ShaunHalverson
      @ShaunHalverson  3 ปีที่แล้ว

      Are you calling the right button method when you click enter?

    • @jonathanj2666
      @jonathanj2666 2 ปีที่แล้ว

      @@ShaunHalverson I'm having the same problem, and yes, i've quadruplechecked. Did you ever find a solution? Or perhaps it worked for you?

    • @maniac7591
      @maniac7591 2 ปีที่แล้ว

      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.

  • @J3rryChu
    @J3rryChu ปีที่แล้ว

    POV: you don't know about the TableLayoutPanel...