Problem with setting the .Text Property of Text field in VB Script

Posted by: korbif on 21 December 2022, 6:57 pm EST

    • Post Options:
    • Link

    Posted 21 December 2022, 6:57 pm EST - Updated 21 December 2022, 7:04 pm EST

    Hello,

    i have currently a problem with setting the .Text Property of a Text Field in VB Script.

    I try to set the .Text Property with a single char “-” (Pic #1), but i get a exception during rendering (Pic #2)

    I already tried to set the “-” char with the Char(x) function (Pic #3) from VB in order to escape, but without success.

    How can i set “-” to a text field property “.Text”?

    Thank you in advance,

    Korbinian

    Pic #1:

    Pic #2:

    Pic #3:

  • Posted 21 December 2022, 9:28 pm EST

    Hi,

    To resolve this issue. Try to add the below VbScript:

    If calcCustomerId.Text=Nothing or calcCustomerId.Text="0" Then
      calcCustomerId.Text = "-"
    EndIf

    Please refer the attached sample report : CustomReport.zip

    Best Regards,

    Nitin

  • Posted 9 January 2023, 12:50 am EST

    Hello Nitin,

    sorry for the late reply. Unfortunately the solution does not fully work for me.

    The strange thing is, the text field content is set correctly to “-” when the before content was empty or “0” but in the logs i still get the same error “Expression ‘-’: Expression expected. (at line 1, column 1)”.

    Maybe you have a futher idea?

    Thank you in advance

    Korbinian

  • Posted 9 January 2023, 4:19 pm EST

    Hi,

    We didn’t face this issue at our end even in the sample provided by us previously. There are no such errors in that sample.

    Could you please provide the small stripped sample replicating this behavior? So, that we can investigate and assist you accordingly.

    Best Regards,

    Nitin

  • Posted 10 January 2023, 9:52 pm EST

    Hi Korbinian,

    just a guess: is the field set to “Calculated = true”? If yes, FlexReport might try to evaluate “-” as an expression.

    Best regards

    Wolfgang

  • Posted 10 January 2023, 11:59 pm EST

    Hello Wolfgang,

    yes the “Calculated” Property is set to TRUE because we are changing the value via VBScript.

    Maybe i have to somehow escape that “-”? Is there some escape character which i have to put before the “-”? Any idea?

    Regards,

    korbinian

  • Posted 11 January 2023, 2:19 am EST

    Hi everybody,

    the solution was instead of setting my textfield like *.Text = “-”, i must set it to *.Text = Char(45).

    As Wolfgang mentioned before, with the Calculated property set to TRUE, it expects to have some expression to be evaluated and not a single char to write as text.

    Thank you all for your help,

    Korbinian

Need extra support?

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

Learn More

Forum Channels