Lotusscript Format and 6 decimal places

I’d like to format a number with lotusscript up to 6 decimal places which I would always like to show up. I also don’t know how big the number can get. If there are no numbers after the decimal nothing shows up.

Forall columns In dataentry.ColumnValues

			...Format(columns,"(###,###,###,###,###,###.######)")

I could theoretically treat this as text since I’m just sending the information as a report in an email… but I’d like to know the better way for future reference.

many thx

Subject: RE: Lotusscript Format and 6 decimal places

There is a way to do what you want using Format, described in the documentation of that function. Use “0” instead of “#” where you want to force display of a digit even if it’s zero.

I strongly advise against converting a number to text in a view column formula. Not only is this less efficient, it means the view will not adjust the number display to the user’s number formatting selections (e.g. is comma a thousands delimiter or a decimal point?).

Subject: RE: Lotusscript Format and 6 decimal places

Thanks Andre.

The view is strictly used for sending the report via email.

I’m actually using the ReportGenerator class you wrote to send mail.

Subject: one more ?

do I need to account for the largest number with format?

using format(num, “(0,000.000000)”) is sufficient for a number of any size? for 1,234,567.560000 for example?

Subject: RE: one more ?

Yes, that’s OK, you don’t have to account for the number of digits in front of the decimal point, as long as you don’t need a fixed number of leading zeros.

Still not sure how you are going to create your report.

If it just comes to displaying numbers either in a view column or in a form, both - columns and fields - have their own means of formatting (which are more efficient). It’s just if you are creating something completely form back-end data, that you would have to use Format.

Subject: Thank you!

Thanks everyone! Sorry if I was being a bit dense about it and I appreciate all of your responses.

Here’s a piece of my code - I’m still working on it but now it just needs some nuancing on my part:

Thanks again to Andre for the ReportGenerator class he posted (http://www.openntf.org/Projects/codebin/codebin.nsf/CodeBySubCategory/84F37FE2DB46E185862572FD006D5428)

		For xx = 1 To datavc.Count

			Print "Processing Row: " & xx & "/" & datavc.Count & " (" & Round(xx/datavc.count*100,0) & "%)"

			cp=0 ' reset the column position 

			y = 0 ' reset the count for check for hidden columns

			

			Set dataentry = datavc.GetNthEntry(xx)

			

			Forall columns In dataentry.ColumnValues

				If cols(y).ishidden = False Then

					Select Case y

					Case 5 ' SHARES

						rgen.AddText Format(columns,"GENERAL NUMBER")

						

					Case 6 ' PRICE

						rgen.AddText Format(columns,"($#,##0.000000)")

						

					Case 7 ' NET

						rgen.AddText Format(columns,"CURRENCY")

						

					Case Else

						rgen.AddText columns

					End Select

					rgen.NextCell							

					cp= cp + 1

				End If

				y = y +1

			End Forall

		Next

Subject: RE: one more ?

You’d probably want to amend that a bit – only the ones digit and the decimal places ought to be zeroes with the format you want; the tens, hundreds and so on can be octothorpes (unless you really want leading zeroes). You only need to use enough formatting characters to get the thousands separator into the string once, so your format statement would look like this:

Format$(numberValue, “#,##0.000000”)

Subject: RE: one more ?

I know if may seem ridiculous but I could have a field value of:

$1,924.137063

I’ll take it without $ sign but I just want to know if there’s a way to do something like that. They would like me to show the full 6 places…

Large numbers are easier to read punctuated at the thousands as well… (“0,000.000000”) forces leading zeroes on smaller numbers as well…

Subject: Lotusscript Format and 6 decimal places

Not sure if I completely understand what you want to do (and what not).

To force a certain formatting for a number, you HAVE to display/store it as text. Otherwise, a number is always only bound to what the actual datatype permits (or not). There is no way to force a real number to always have 6 decimal places.

Subject: RE: Lotusscript Format and 6 decimal places

was just hoping there was an easy way… like you can get the field to display 6 places?

ok. I’ll convert the col values to text and read them that way.