Extra trailing zero (0) added to text value in table column using NotesRichText classes

I am creating a table in a rich text field using the Notes Rich Text classes.

In the last cell of the table – the lower right cell of the table – I am adding text using the AppendText method. The text is a number that I convert to a string before I insert.

Here is the issue: It is adding a trailing zero to the text. For example if it is 54, it puts in 540.

I put this through the debugger and the value of the field on the actual document is set to 54 right before I call the AppendText method.

There are other values like this that I add to the table that do not add the trailing zero.

Here is the code snippet:

Call rtNavBody.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rtBody.BeginInsert(rtNavBody)

totalHours = Cstr(doc.TOT_T(0))

'totalHours = Format$(Cstr(doc.TOT_T(0)), "00")

'Call rtBody.AppendText(Cstr(Cint(totalHours) / 10))

Call rtBody.AppendText(totalHours)

Call rtBody.EndInsert

As you can see I even tried formatting the text to two characters as well as dividing by 10.

No luck on either – it is adding the zero somewhere in the AppendText method.

Any ideas?

Thanks!

Dan

Subject: Extra trailing zero (0) added to text value in table column using NotesRichText classes

magic. One idea is that the cell already contains “0”, so you just add your 54 in front of it when you run your code. Other idea – you maybe call your code twice for some reason and in the first case your formatted string is “0”.

Subject: RE: Extra trailing zero (0) added to text value in table column using NotesRichText classes

You’re idea was right — there was a 0 in the cell already…

I was looping through the rows, but when I added the last row, I did not AddRow to the table, so it just appended to whatever was in the cell…

Got it – thanks a lot!

Dan