Bogemic Software        Bogemic Software RSS  Subscribe: RSS       Products  |  Purchase  |  Support  |  Contact      
Products
  Bogemic Apps
  Bogemic Docs
  Bogemic Studio
  Bogemic Grid
  Services
Order Now
Ordering Process
Documentation
Press Releases
Reseller
Feedback Form
Technical Support
Contact

Data formatting

« Back Forward »

Properties: Property(Prop_Format)

Formatting date and time

If the cell has the Prop_DataType property set to DataType_Date or DataType_Time then the following code can be used:

' suppose we have the English (USA) locale
' set the cell value to 14th February 2008
Set cell = grid.Cell(0,0)
cell.Property(Prop_DataType) = DataType_Date
cell.Value = "2/14/2008"

' define the following format:
' <day of week>, <day of month> <name of the month> <year>
cell.Property(Prop_Format)="%day, %d %month %YYYY"

To get the formatted text use the FText property of the Cell object. Now change the DataType property to DataType_Time and format the value again:

cell.Property(Prop_DataType) = DataType_Time
' for the English (USA) locale the time
' should be specified as "h:mm:ss tt"
cell.Value = "11:14:00 AM"

Now format the time:

cell.Property(Prop_Format) = "hour:%hr, min:%mn, sec:%sc"

Formatting currency

Now set the DataType property to DataType_Currency and see the formatting options for this type:

cell.Property(Prop_DataType)=DataType_Currency
cell.Value = 100

suppose we have the English (USA) locale, so the currency abbreviation is USD:

' %s - is a string represenation of the cell value
' %cur - is a currency abbreviation for the current user locale cell.Property(Prop_Format) = "%s %cur"

if we would like to place the "$" before the value, we will do the following:

cell.Property(Prop_Format) = "$%s"

Formatting numbers

Set the DataType property to DataType_I4 and format an integer value:

cell.Property(Prop_DataType) = DataType_I4
cell.Value = -123

Format the value as a signed integer:

cell.Property(Prop_Format) = "Total balance is: %n USD"

Format the value as a non-negative integer:

cell.Property(Prop_Format) = "Total value is: %u USD"

Set the Prop_DataType property to DataType_R4 and format the value as a floating point type:

cell.Property(Prop_DataType) = DataType_R4
cell.Value = 3.14159265
' set the precision to 4 digits after the decimal point
cell.Property(Prop_Format) = "PI = %.ffff"

To output the "%" symbol, you should use the "%%" format specifier. To format the cell value as a string use the "%s" format specifier.

« Back Up Forward »