Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Just a quick simple one - if/then/else syntax!

Posted on 2009-04-19
6
Medium Priority
?
333 Views
Last Modified: 2013-11-23
Below is my code, somehow managed to mess up the syntax but my tired eyes can't see where I've gone wrong!

Cheers!
procedure TFrmEPOS.BtnTransactionVoidClick(Sender: TObject);
var count: integer;
begin
  if BtnEposTotal.Enabled = true then
    for count := 0 to Strrow do
      StrGridTransaction.Cells[1,Strrow]:='';
      StrGridTransaction.Cells[0,Strrow]:='';
    else
      Strrow := Strrow +1;
      for count := 0 to Strrow do
        StrGridTransaction.Cells[1,Strrow]:='';
        StrGridTransaction.Cells[0,Strrow]:='';
      MmoTransactionTotal.Text:='';
      BtnEposAdd.Enabled := true;
      BtnEposDelete.Enabled := true;
      BtnEposQuantity.Enabled := true;
      BtnEposTotal.Enabled := true;
end;
 
end.

Open in new window

0
Comment
Question by:TTRMW
  • 3
  • 3
6 Comments
 
LVL 6

Accepted Solution

by:
JosephGlosz earned 1000 total points
ID: 24181341
I think you just had to flesh out a few bracketing begin/end's...

  if BtnEposTotal.Enabled then
    for count := 0 to Strrow do
      begin
      StrGridTransaction.Cells[1,Strrow]:='';
      StrGridTransaction.Cells[0,Strrow]:='';
      end
    else
      begin
     Strrow := Strrow +1;
      for count := 0 to Strrow do
        begin
        StrGridTransaction.Cells[1,Strrow]:='';
        StrGridTransaction.Cells[0,Strrow]:='';
        end;
      MmoTransactionTotal.Text:='';
      BtnEposAdd.Enabled := true;
      BtnEposDelete.Enabled := true;
      BtnEposQuantity.Enabled := true;
      BtnEposTotal.Enabled := true;
    end;
0
 

Author Closing Comment

by:TTRMW
ID: 31572066
Cheers!
0
 

Author Comment

by:TTRMW
ID: 24181354
Worked great, cheers for that. However it completely failed to clear my string grid which was frustrating, not sure what's going wrong there.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:JosephGlosz
ID: 24181477
oh, that is probably because the for loop increments count from 0 to strrow, but does nothing with the count. Instead of

for count := 0 to Strrow do
      begin
      StrGridTransaction.Cells[1,Strrow]:='';
      StrGridTransaction.Cells[0,Strrow]:='';
      end

for count := 0 to Strrow-1 do
      begin
      StrGridTransaction.Cells[1,Count]:='';
      StrGridTransaction.Cells[0,Count]:='';

(since count is 0 based, I think you might want it to be strrow-1 not just strrow....

      end
0
 

Author Comment

by:TTRMW
ID: 24181489
Ah cheers man, great stuff. I made a separate question for it, if you post on there I'll allocate points. Thanks muchly.
0
 
LVL 6

Expert Comment

by:JosephGlosz
ID: 24181500
I was typing the other question at the same time...  cheers! :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

578 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