How to use Sub-Parameter into vbScript (FlexReport)

Posted by: c1 on 22 January 2020, 8:08 pm EST

    • Post Options:
    • Link

    Posted 22 January 2020, 8:08 pm EST

    Hello folks,

    i use FlexReport and need to set the color (and other attributes) of some textfields depending on the shown values. Code like this works fine into the onPrint Event:

    ' Set Color to Red if Value is negativ 
    fldSaldo_1.foreColor = Rgb(0,0,0)
    if CInt(fldSaldo_1.Text) < 0 then 
       fldSaldo_1.ForeColor = Rgb(233,0,0)
    endif
    

    Because of the number of fields and the things to do with one field i try writing a function (placed as globalScript) like this

    Sub setFieldColor(oneField)
      oneField.foreColor = Rgb(0,0,0)
      if CInt(oneField.Text) < 0 then 
         oneField.ForeColor = Rgb(233,0,0)
      endif
    End sub
    
    

    I like to call this by

    call setFieldColor( fldSaldo_1 )

    But instead to change the color of the textfield this code set the value to 233 :slight_smile:

    How can i use as TextField as parameter for a sub?

    Thanks in advance for any help.

    Niels

  • Posted 24 January 2020, 8:33 pm EST

    Hi folks,

    in addition to this topic i like to know where i find documentation about vbScript. Is there any more detailed documentation availible as in: FlexReport for Windows (PDF) Section: Work with VBScript?

    Thanks in advance for any hint.

    Niels

  • Posted 26 January 2020, 10:54 pm EST

    Hello Niels,

    How can i use as TextField as parameter for a sub?

    We are investigating on this and will get back to you once it is done (Internal Tracking ID: 418487).

    However, using RGB generated color and did not set the value to the TextField. Refer the attached report showing the same.

    The documentation for VB Script is:

    https://www.grapecity.com/componentone/docs/win/online-flexreport/WorkingwithVBScript.html

    There are various subsections under this topic.

    Regards,

    Esha

    Test.zip

  • Posted 4 February 2020, 6:26 pm EST

    Hi Esha,

    thanks a lot for your answers.

    The online documentation (following the given Link) hold same information like the FlexReport-PDF File.

    What i am missing:

    1. how to define own variables (whats about the visiblity into different code sections (private, public), which datatypes are available)
    2. Which datatype are TextFields, Labels, SubSections. Is there a global Type like Control and so on …
    3. How can I use variables as parameters.

    In this case my topic was solved by a lot of copy and paste code. Not fine, but solved :slight_smile:

    Best greetings.

    Niels

  • Posted 5 February 2020, 10:25 pm EST

    Hello Niels,

    1. You can declare your own variables in Report.GlobalScript event to use it in various events. For example, declare this in GlobalScripts:
    testfld=0    
    

    Then, assign the same to a field, in Detail.OnFormat after changing the value:

    testfld=30
    Field1.Text=testfld
    

    https://www.grapecity.com/componentone/docs/win/online-flexreport/VBScriptElementsObjectsandVariables.html

    Regarding the supported datatypes, refer the VBScript related documents online as C1FlexReportDesigner uses the same in the script: https://docs.microsoft.com/en-us/previous-versions//3ca8tfek(v=vs.85)?redirectedfrom=MSDN

    1. FieldBase class is the abstract base class for all the C1FlexReport field types:

      https://www.grapecity.com/componentone/docs/win/online-flexreport/C1.Win.FlexReport.4.5.2~C1.Win.FlexReport.FieldBase.html

      The fields within the report are fetched directly in the designer’s script from the “Report Fields” option in the menu, in VBScript Editor.

    2. This is related to the previous inquiry, and I shall get back to you with a response for this and the previous question, once the investigation is done.

    Regards.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels