How to insert literals in a TfrxMemoView

I have an 8 digit value that I want to display in a TfrxMemoView with a dash "-" inserted between every two digits. For example the original value coming from the data field is 12345678 and I want it to be displayed as 12-34-56-78. How can I achive this. Obviously I have to use FormatStr property but could ot figure it out.

Can someone provide me the FormatStr to achive the above result, or suggest some other solution.

Comments

  • renerene Prague, Czech Republic, Europe
    edited 4:22PM
    First idea: If it has fixed length try to use Copy function like:
    var
      mytext: string;
    
    ...
    
    { Handler: OnBeforePrint }
    begin
      mytext := <GET_FIELD_TEXT_IN_HERE>;
      mytext := Copy(mytext, 1, 2) + '-' + Copy(mytext, 3, 2) + '-' + Copy(mytext, 5, 2) + '-' + Copy(mytext, 7, 2);
    end;
    

    But maybe it could be done more sofisticated way by MaskEdit or FormatStr aso.
  • edited 4:22PM
    It is not a fixed size field therefore this approach wouldn'g work.

    Still waiting for someone to help in using the FormatStr to insert literals in a string in specific places.

Leave a Comment