Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Validation- Yes/No Posted by sarkiemarkie on 3 Jan 2006 at 4:17 PM
procedure TForm4.ComboBox1Exit(Sender: TObject);
var ok:boolean;
begin

ok:=false;
if upcase(combobox1.text) = 'YES' then ok:=true;

if upcase(combobox1.text) = 'NO' then ok:=true;

if ok=false then combobox1.Color:= clLime
{if any of the above in incorrect then make the colour lime green to show error}
else if length(combobox1.Text)=0 then combobox1.Color:=clred
{if there is nothing there, the box goes red}
else combobox1.color:=clWhite;
{otherwise it remains white}
end;

end.


it will accept YES and NO but not yes or no. And upcase doesn't work, it says:

"[Error] Unit4.pas(495): Incompatible types: 'Char' and 'TCaption'"

HELP!!
Report
Re: Validation- Yes/No Posted by zibadian on 3 Jan 2006 at 11:30 PM
:
procedure TForm4.ComboBox1Exit(Sender: TObject);
: var ok:boolean;
: begin
: 
: ok:=false;
: if upcase(combobox1.text) = 'YES' then ok:=true;
: 
: if upcase(combobox1.text) = 'NO' then ok:=true;
: 
: if ok=false then combobox1.Color:= clLime
: {if any of the above in incorrect then make the colour lime green to show error}
: else if length(combobox1.Text)=0 then combobox1.Color:=clred
: {if there is nothing there, the box goes red}
: else combobox1.color:=clWhite;
: {otherwise it remains white}
: end;
: 
: end.

:
: it will accept YES and NO but not yes or no. And upcase doesn't work, it says:
:
: "[Error] Unit4.pas(495): Incompatible types: 'Char' and 'TCaption'"
:
: HELP!!
:
If you want to upcase a string use the UpperCase() function.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.