trying to create an atm
i wanna create an atm system that only draws out 100 dollar bills. So if you wanna draw out 670 dollars an error would pop out that tell you hat youre only able to withdraw 600 dollars but the code isnt running
12 Replies
You need to reference the Text property of the label
how do i do that?
lblPengar.Text
otherwise you're referencing the label itself and assigning it, which fails cause the value is string
ohhhhh i thoguht that only applied to textboxes
All controls
All you can set in the designer you can set in code through properties of the control
Funny enough if you look at the Designer.cs file, you'll find it's generating the entire form with the same lines you would use to modify it in code
The designer just helps generating the designer file
its not working as its supposed to hahaha
You're converting to Int and setting to double so you lose precision
If it's intentional to round down, you can also do this by casting
var rounded = (int)decimalValue
ill try that thanls for the help
thanks
also for converting from string to number, always use TryParse
int.TryParse("1", out var num)
thats what my teacher told me but im used to convert.toint32
The problem with that is it will crash if you enter something that's not a number
With TryParse you can put that in an if and if it returns false you can abort and send an error message
thanks a lot for the advice
ill keep that in mind
i appreciate the help a lot