[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Checkbox

Posted on 1999-11-02
5
Medium Priority
?
222 Views
Last Modified: 2010-04-04
Simple really....(Getting old,so cant
remember simple things ....)
I have a checkbox and a button
(button1 and checkbox1).
Declared
Var checked :boolean;
for the form.
Then wrote on buttonclick:
IF checkbox1.checked := True THEN
application.terminate
ELSE
Showmessage('Whatever')
end;
Then I cant compile because compiler gives me error:
"Type of expression must be boolean"
What am I doing wrong?
0
Comment
Question by:srbenavrbe
  • 3
5 Comments
 
LVL 6

Accepted Solution

by:
wimmeyvaert earned 120 total points
ID: 2179116
Hello,

The answer to your question is also simple :
In an IF-statement you can't use an assignment (:=). You have to make a comparison between 2 values (=, <>, >, <, ...).
Below the correct code :

IF checkbox1.checked = True THEN
  application.terminate
ELSE
  Showmessage('Whatever');


Or even Better :

IF checkbox1.checked THEN
  application.terminate
ELSE
  Showmessage('Whatever');


Hope your problem is solved now.
0
 
LVL 1

Expert Comment

by:Indefrei
ID: 2181315
You better use
If checkbox1.State:=cbchecked then
   // do whatever
else
   // blabla
regards
Indi
0
 
LVL 1

Expert Comment

by:Indefrei
ID: 2181324
Oops, eliminate the >> : << , which has been the mistake before
0
 

Author Comment

by:srbenavrbe
ID: 2182168
Ohh ...I get it!
Just one more tiny Q (with points ofcourse)...
If I were to add another request to my
code,example:
IF checkbox1.checked = True THEN
  Showmessage('Whatever');
Mediaplayer1.Play
Else
......
What is the right syntax as (;) is
not alowed before ELSE ?

0
 
LVL 1

Expert Comment

by:Indefrei
ID: 2184428
IF checkbox1.checked = True THEN
begin                    
   Showmessage('Whatever');
   Mediaplayer1.Play;
end
Else
begin
     .
     .
end;
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question