format() function inside a memo

edited December 2014 in FastReport VCL 5
I have memo control that contain value like this

[fdataset."field_name"]

This produce numbers like 1, 2, 3 so I want it to format it to be like this 001, 002, 003 . I tried to use format but I always get error, please advise what syntax I should use for format
function ?

Another question I tried to write in the code script syntax like that
wrote:
var
vNo3: string;

procedure ReportTitle1OnBeforePrint(Sender: TfrxComponent);
begin
vNo3 := <frdsMain."DAY_SEQ"> +'-'+ copy (<frdsMain."SQ_ID">, 1, 2);
end;

I am trying to get numbers like this 2-3 but I always get error Could not convert variant of type (UnicodeString) into type (Double) although both fields has numbers.

please advise

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 5:00PM
    1 make sre you have not set a numeric format for the memo view use plain text
    in the first case leave the content of the memo empty
    2 in the obp event of the band containing the memo get the value of the datafield and convert to a string
    and add that string to your tempstringvariable then set the memo text to the tempstring value
    3 in the second case turn allow expressions for the memo off
  • edited 5:00PM
    gordk wrote: »
    1 make sre you have not set a numeric format for the memo view use plain text
    in the first case leave the content of the memo empty

    Thanks but when I tried to write the format function inside the memo I get error , here is what I tried:
    gordk wrote: »
    [Format('000', <dataset."field_name">)]


  • gpigpi
    edited 5:00PM
    First way: set TfrxMemoView.DisplayFormat.Kind to fkNumeric, TfrxMemoView.DisplayFormat.FormatStr to 000
    Second way: [Format('000', [<dataset."field_name">])]
  • edited 5:00PM
    wrote:
    Second way: [Format('000', [<dataset."field_name">])]

    This way result in printing 000 although [dataset."field_name"] alone print 2
  • gpigpi
    edited 5:00PM
    Use [FormatFloat('000', <dataset."field_name">)] or set FormatStr
  • gpigpi
    edited 5:00PM
    Or read about Delphi's Format parameters and use
    [Format('%3.3d', [Round(<dataset."field_name">)])]
  • edited 5:00PM
    gpi wrote: »
    Use [FormatFloat('000', <dataset."field_name">)] or set FormatStr

    Thanks formatfloat work fine

  • Thank you so much this comment has saved my life watered my crops and thatched my roof.

    I spent forever pulling my hair out about this error but I had accidentally set a random Memo box to Time/Date Format and didn't even think to check that

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.