Search code examples
delphi-7

Assigning value to each number from TSpinEdit


I have a TSpinEdit named seVal, its min value is at 0 and the max is 10. I need to assign a value to each number, except 0 which needs to report an error message, and then display that value in a Label. I've not delt with TSpinEdit's that much so any coding to do with them is not familiar to me.


Solution

  • case seVal.Value of
      0: Label1.Caption := ...;
      1: Label1.Caption := ...;
      2: Label1.Caption := ...;
      ...
    end;
    

    Or:

    const
      LabelValues: array[0..10] of String = ('...', '...', ...);
    
    Label1.Caption := LabelValues[seVal.Value];