Forum Discussion

gdave's avatar
gdave
Regular Contributor
7 years ago

Code Expression - Rounding Off

Hi all   Using below code express I was able to validate that value in field 2 is 25% of value in field 1.   aqConvert.VarToStr(Aliases.TransactConsole.omTransactFormWizardView.PanelDataEntry...
  • tristaanogre's avatar
    tristaanogre
    7 years ago

    If it's DelphiScript that you're coding on, you can use the Round function but after a bit of mathematical manipulation.

     

    So... got to brush off my math undergraduate degree a bit.

     

    Round(Aliases.TransactConsole.omTransactFormWizardView.PanelDataEntry.PanelForm.FormTaxFreeWithdrawal.PanelMain.ScrollBoxAroundForm.PanelTFCFacInfo.GroupBoxTFCFac.EditFundValueFac.wText * 25)/100

    Basically, taking the value of field one, multipliying by 100 to move the decimal point then multiplying by 0.25 (net multiply by 25).  Then, using the Delphi Round method available in TestComplete to round to the nearest integer...then dividing by 100 again to get the decimal point.

     

    Give this a try.