Forum > General

Formatting textbox result

(1/4) > >>

Dmitri Dumas:
Good afternoon. I am new to Pascal / Lazarus. Here is my situation. I need to calculate two textbox values and display them in another on.

procedure TfrmZFW.edtAvgBagsPerPaxExit(Sender: TObject);
begin
  edtTotalBagPieces.text := FloatToStr(StrtoFloat(edtBookedPax.text) * StrToFloat(edtAvgBagsPerPax.Text));
end;

When the user exits the above text box (Edit box), the result is displayed in the edtTotalBagPieces textbox. There are times when the number is a decimal. I have tried various methods to round the result so that it does not display any decimals. For example if the number is 263.3 it should display 264 (Always to the next highest number.

Any suggestions would be highly appreciated.

Kind regards
Dmitri

RAW:
 :D :D :D

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---PROGRAM Project1;  VAR  dNumber: Double;  iResult: Integer; BEGIN dNumber:= 263.3; iResult:= Trunc(dNumber)+1;  WriteLn(iResult);  ReadLn;END.

Dmitri Dumas:
Thank you. However, the number will vary each time. This is an application to calculate the number of passenger bags. For example. If there are 202 passengers booked and the average number of bags is 1.3 per passenger, the result will be different from 197 passengers booked. Will try to upload a screenshot :)

RAW:
Something like this... perhaps...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Procedure TForm1.FormClick(Sender: TObject);  Var   dNumber: Double;   Function MyRound(dNum: Double): Integer;   Begin    Result:= Trunc(dNum)+1;   End;  Begin  dNumber:= 113.55;   Edit1.Text:= IntToStr(MyRound(dNumber)); End;

Dmitri Dumas:
Afraid not. When the user exits the textbox the result will automatically display.

Navigation

[0] Message Index

[#] Next page

Go to full version