Practical lesson
In the practical lesson three applications for working with Edit are created. The first is the “Character counter”: a word is typed in Edit1 and when the button is pressed Label1.Caption := 'Belgilar: ' + IntToStr(Length(Edit1.Text)); appears. Length also counts spaces and punctuation. The second is “Capital letters”: Edit2.Text := UpperCase(Edit1.Text); converts the text to capitals (UpperCase comes from the SysUtils unit, which is normally connected already in a new application). The third is clearing: in the OnChange event of Edit1 (double-click in the Object Inspector on the Events tab) write Label1.Caption := ''; so that the out-of-date character count disappears as soon as the text changes. In each application write the expected results in your notebook before testing.
In an entry box a code might be typed as “ab12” or as “AB12”. The program automatically changes the text to capital letters and treats both as the same. The user is not turned away because of a tiny difference.
Programmers, data-entry staff and developers of search systems bring text to one form before comparing it.
Think up a slogan for a school poster that is no longer than 30 characters and count its characters, spaces included.
1procedure TForm1.Edit1Change(Sender: TObject); 2begin 3 Label1.Caption := ''; 4end;
“The character counter”: each student writes 5 words in a notebook and calculates Length in advance; checks with the pair’s application and writes the reason for any difference.