Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { DFM }
- object Form1: TForm1
- Left = 0
- Top = 0
- Caption = 'Form1'
- ClientHeight = 214
- ClientWidth = 266
- Color = clBtnFace
- Font.Charset = DEFAULT_CHARSET
- Font.Color = clWindowText
- Font.Height = -11
- Font.Name = 'Tahoma'
- Font.Style = []
- OldCreateOrder = False
- PixelsPerInch = 96
- TextHeight = 13
- object Label1: TLabel
- Left = 88
- Top = 112
- Width = 31
- Height = 13
- Caption = 'Label1'
- end
- object Button1: TButton
- Left = 80
- Top = 64
- Width = 75
- Height = 25
- Caption = 'Button1'
- TabOrder = 0
- OnClick = Button1Click
- end
- object SpinEdit1: TSpinEdit
- Left = 64
- Top = 24
- Width = 121
- Height = 22
- MaxValue = 0
- MinValue = 0
- TabOrder = 1
- Value = 42
- end
- end
- { PAS }
- unit uMain;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Label1: TLabel;
- SpinEdit1: TSpinEdit;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- const
- Ends: array[0..9] of String = ('th','st','nd','rd','th','th','th','th','th','th');
- function IntSuffix(const Number: Integer; const AddSpace: Boolean = False;
- const SuffixOnly: Boolean = False): String;
- begin
- if not SuffixOnly then begin
- Result:= IntToStr(Number);
- if AddSpace then Result:= Result + ' ';
- end;
- if ((Number mod 100) >= 11) and ((Number mod 100) <= 13) then
- Result:= IntToStr(Number) + 'th'
- else
- Result:= IntToStr(Number) + Ends[Number mod 10];
- end;
- (*
- $ends = array('th','st','nd','rd','th','th','th','th','th','th');
- if (($number %100) >= 11 && ($number%100) <= 13)
- $abbreviation = $number. 'th';
- else
- $abbreviation = $number. $ends[$number % 10];
- *)
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Label1.Caption:= IntSuffix(SpinEdit1.Value);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement