Monday, July 25, 2016

VB Script Very Useful Function - RDLC Report

Hello Friends,

I have identify some of the very useful VB Script function in RDLC Report which helps many times to design reports in RTC reports.

 1)      Percentage calculation using function in VB Script code (Copy from standard USA 10048 Report)


In class version there is code in on section trigger to calculate the percentage










Now in RTC we need to create the VB script function for same to calculate the percentage value


Shared Pct as Decimal
Public Function CalcPct(Amount as Decimal, Profit as Decimal) as Decimal
    if Amount <> 0 then
       Pct = 100 * Profit / Amount
    else
       Pct = 0
    end if
    REM Rounding precision = 0.1
    Return ROUND(10*Pct)/10
End Function


In the Textbox expression define the following expression









2)      Get the Unit Cost value by divide Amout by Qty using VB Script Function (Use in Standard NA 10139 Report)
      
 Note:
 If you directly divide the value in expression than RDLC Report is failed to Handle Divide by Zero  exception
 Not Working  ---  IIF(Fields!UnitCost.Value <> 0, Fields!Amount.Value/Field.UnitCost.Value,0)

 Define the function in report:

Public Function CalcUnitCost(Inventory as Decimal, Remaining as Decimal)
    if Remaining = 0 then
        return 0
    end if
    return Inventory/ Remaining
End Function
































Expression: =Code.CalcUnitCost(Sum(Fields!InventoryValue.Value),Sum(Fields!RemainingQty.Value))































3)      Comment in VB Script function

Use the ‘ (single quote) to write comment  in function



































i will update the more useful function very soon.

I hope it will help you in future.

Keep Sharing...Keep  Growing !!!

2 comments:

  1. tere lie jhumma jhumma chumma

    ReplyDelete
  2. The comparison between NAV 2017 and Dynamics 365 for Financials is an important aspect to consider for businesses seeking the right financial management solution. NAV 2017 has established itself as a robust and reliable option, offering a wide range of features and customization capabilities. On the other hand, Dynamics 365 for Financials brings the advantages of cloud-based accessibility and integration with other Microsoft tools. It offers a more streamlined and scalable solution for businesses looking to leverage advanced analytics and automation. Ultimately, the choice depends on specific business requirements, scalability needs, and preferences for cloud-based solutions.Express VPN give 1 month free plan




    ReplyDelete