Interbase – How to manually round calculate 3rd decimal [SOLVED]

I have seen a few computations done in interbase and a lot of them have trailing decimals after them and if we want to round them manually, this is what I have come up with.

Suggestions and alternative solutions are always welcome. I am using a few variables so I can see the results of the computation as they unravel.

/* 889.125 */
VINT1 = (PANNUAL_TAX * 100);
VAMT1 = (VINT1 / 100);

VINT2 = (PANNUAL_TAX - VAMT1) * 1000;
VAMT2 = VINT2;

IF (VAMT2 >= 50) THEN
     VAMT3 = VAMT1 + 0.01;
ELSE VAMT3 = VAMT1;

PANNUAL_TAX = VAMT3;

The PANNUAL_TAX is the variable that holds the 2 decimal result.

Enjoy,

Coffee Cup

Delphi: Check Internet Connection [SOLVED]

Recently a lot of apps right now are becoming internet dependent. Currently the project I am working on requires the system to know if there is internet or not.

Here is the code snippet I found

uses WinInet;
 
var
  origin: cardinal;
begin
  if InternetGetConnectedState(@origin,0) then
    ShowMessage('Connected!')
  else
    ShowMessage('Not connected')
  end;
end;

Enjoy

Coffee Cup

 16 total views,  1 views today

PHP File going to Microsoft Excel “The file is corrupt and cannot be opened” [solved]

Encoutered this issue with a website I was working on. When i convert the data to excel it comes out with message “The file is currpt and cannot be opened”.

When I tried to do research I found a page that says you open the file using notepad and then save it. Once done, you can open it normally.

To my end I was able to solve it by moving the access codes (user , password , database) of the mysql to the actual page itself. Usually I reference it from another php page. But this time, moving it solved my problem

Hope this helps somebody out there

Coffee Cup

Dephi and Quickreport – How to get Page Number

Hi guys,

Recently I encountered a challenge in quickreport that has 2 specific criteria. The invoice report I was making needs to behave both as a page footer and a summary band.

Well the page footer needs to stay because there was a gap at the bottom to write the page number and signature boxes. The summary band comes in because the total amount of the invoices needs to be positioned at the bottom

How to solve it. I took the total number of pages and when the report reaches the last page, the system will display the total amount

  1. Quickreport needs to have a PageHeaderBand
  2. Inside the PageHeaderBank BeforePrint event handler you can ask for the QuickREport1.QRPrinter.PageNumber

Those were the 2 tips that I got from stockoverflow. Really big help for me.

Hope this article helps

Coffee Cup

Delphi Buttons – Create an hour glass impression while waiting

Got a chance to receive source code from a software vendor and the button on this program made me smile.

Haven’t though of it that way. But i think it works.

procedure TSFTPClientFrame.btConnectSSHClick(Sender: TObject);
var
  OldCursor: TCursor;
begin
  OldCursor := Screen.Cursor;
  try
    Screen.Cursor := crHourGlass;
    ScSSHClient.Connect;
  finally
    Screen.Cursor := OldCursor;
  end;
end;

The hour glass cursor is within the try row. Once it is done, it revert backs the cursor to the original one used. Pretty awesome.

Just wanted to share

Coffee Cup

Oracle Virtual PC – menu missing [solved]

It’s been days since the menu on top of virtual pc dissapeared after I chose the fullscreen mode. Good thing there is google.

Found the switch. And it is RIGHT-CONTROL yeah, not the left control key. It’s RIGHT+CONTROL + C

Viola! Enjoy!

Coffee Cup

Storing Chinese Characters in Mysql / Chinese Characters Not Working in MySQL

Recently transferring to another website, the chinese characters are not working already.

Googling the answer led me to this code, you can convert existing columns one by one, or else you can convert them all at once this way:

mysql> ALTER TABLE nameTable CONVERT TO CHARACTER SET utf8mb4, COLLATE utf8mb4_bin;

mysql> SHOW CREATE TABLE nameTable\G

CREATE TABLE `nameTable` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `version` bigint(20) DEFAULT NULL,
  `country` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `englishName` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `chinesename` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin 

After running the code made it ok

Thank you for the web

Coffee Cup

Delphi Tip : How to get the value from TQrExpr Quick Report Component [solved]

Hi guys,

Just wanted to post this quick tip for those who are still using Delphi and wanted to get the value whether double or int when computing using TQrEXPR.

I remember already seeing this before and now I might need to post it here for posterity sake.

Hope it helps someone else out there. The concept is QREXPR1.Value.DblResult or IntResult.

case QRExpr1.Value.Kind of
resInt : Total := QRExpr1.Value.IntResult;
resDouble : Total := QRExpr1.Value.DblResult;
else
Total := 0.00;

Yeah it’s that easy.

Take care and stay safe

Coffee Cup