I'm new to programming, I'm looking to make a command to add and subtract values.
Where I would have a TEdit.Value
with the initial value 0
and 2 more buttons, one of " + " and one of " - ", to increase or decrease the value, but I still don't know how to do that, can someone give me one light?
I looked up some examples of how to do this, but I didn't find anything that could help me.
You could use
StrToInt()
to convert the Edit's currentText
string to an integer, then increment/decrement the integer, then useIntToStr()
to convert the integer to a string and assign it back to theText
property. For example:However, a better option would be to use a UI control that is specifically designed to handle numeric input, such as a
TSpinEdit
, or aTUpDown
attached to an Edit control.