TMaskEdit for Date curious behaviour when enter mask char - delphi

I am using a mask edit to create a TDateTime component.
I use the following mask: !99/99/0000;1;_
It works fine save that if as the user enters the date they also type the date separator, if they are on the second section (ie the month or the day depending on your locale), the cursor jumps to the year section. If you are on the year section it beeps.
I have tried capturing the dateSeparator in keydown of the component and although I intercept it and set it to 0 it nevertheless jumps from the day/month section to the year section. I even try resetting the selstart after setting the key value to 0, but it doesn't work.
Any ideas as to how to overcome this behaviour would be appreciated.

Not quite an answer to my question, but I solved the issue by using OnKeyPress instead of OnKeyDown and inserting the following code:
if (key = FormatSettings.DateSeparator) then
key := #0;

Related

Tick checkbox for timestamp in google sheet

I'm creating a request/problem form in google form and responses are viewable and editable in google sheet. In the google sheet, I would like to have a timestamp checkbox for myself to whenever I'm done with the problem.
It is look like this
...
Also, This is the function I put in column K(the timestamp) and the column J is the checkbox column.
=ArrayFormula(IF(ROW(K:K)=1,"DATE",IF(ISBLANK(K:K),"DATE",IF(J:J = true,IF(K:K<>"",K:K,NOW()),""))))
The column K function in sheet
The function for column K work as intended and I just need to manually add the checkbox in column J which is fine enough.
But, the problem is happen when a new form is submitted and update the google sheet. Error message appear " "array result was not expanded because it would overwrite data in K81."
The problem
My objective as I mention above is to have a timestamp checkbox for each problem submitted by google form. Is there are any way to work around this?
This error comes up when a function returns an array that is too big to display because something's in its way.
It could be that K81 has a whitespace character in it. Select the whole column under K1 and press Delete. It should remove any content that's not as obvious that it's there.

How to check whether or not a particular cell value is modified in Google Sheets

I am a beginner in Google Sheets. I want to know how I can detect a cell value is changed.
Here is what I am trying to do:
I have two columns in the Sheets, one is the 'Modified Date', one is 'Value', i.e,
Modified Date Value
---------------------------------
09/21/14 5
I want the date to be automatically updated ONLY if the value of the second column is Changed. For example, if I change '5' to '10' on Jan 1st 2015, then the date will be changed automatically to 01/01/15.
I was trying to create a custom function isModified() and assign a function like "=IF(isModified(B1), today(),)" to the first column, where isModified ideally should return true if the given cell's value is modified, false otherwise. Is there any built-in function or custom function in add-ons store that does like isModified()? If not, how can I create my own function that detects the modification of a cell's value?
Please help.
All you have to do is to implement the simple trigger onEdit(event). Following a possible solution:
function onEdit(e){
var range = e.range;
if (range.getColumn() == 2){
var previous = range.offset(0, -1,1,1);
previous.setValue(Date());
}
}
On the proposed solution, the hole date and time is written in the cell "Modified Date". I did this way to make sure the script is working fine. In the case you want just the date, you can change Date() by new Date().
Hope it is useful! If not, let me know:)

Lotus Notes - <Computed text> issue

I have an editable field called Number. This field value changes to "" every time a button is clicked.
So, I want to display its value using a < Computed Text > using as default value Number.
Is there any chance after the button was clicked, the < Computed Text > to display the 'old' value from the field Number?
Thanks!
Yes. You just need to store that old value somewhere before you clear it:
Field OldValue := Number;
And then retrieve it later:
Number := OldValue;
#Command([ViewRefreshFields]);
As I've understood you need to use Help Description and Field Hint in field properties instead of your combination of computed text and event handlers.
Use computed for display field with formula:
#If( #IsDocBeingLoaded; Number; #ThisValue )
That way it will show value of Number field since opening.

Getting coordinates of an ExcelRange object

In Excel's COM API:
Given an ExcelRange object, how would I determine which rows and columns are contained within it?
I do not want the contents of the range, just the "coordinates" of the range, preferably as integers.
I did notice that ExcelRange has both a Row and a Column property, however these only indicate the row and column of the upper left corner of the range.
Note: I am using Delphi, however this question could be relevant to any language using Excel though COM, so answering using Delphi is not necessary.
Assuming a simple rectangular range then you use the Rows and Columns properties of the ExcelRange object. The top-left of the selection is determined by Range.Row and Range.Column. The number of selected rows and columns is given by Range.Rows.Count and Range.Columns.Count.
In complete generality an Excel range can be made up of multiple non-contiguous areas. In this case you use the Areas property of ExcelRange to iterate through the simple rectangular ranges that make up the complex range.
To illustrate consider the following code:
procedure DescribeExcelRange(const Range: ExcelRange);
var
AreaIndex: Integer;
Area: ExcelRange;
begin
for AreaIndex := 1 to Range.Areas.Count do
begin
Area := Range.Areas[i];
Writeln(Format(
'Area %d: R%dC%d:R%dC%d',
[AreaIndex, Area.Row, Area.Column,
Area.Row+Area.Rows.Count-1, Area.Column+Area.Columns.Count-1]
));
end;
end;
I have not actually tested this code so I hope I have remembered correctly that indexing is 1-based.

Zeoslib - loop over calculated fields

I have a Delphi 7 project using Zeoslib 6.6.6 and Sqlite3.
On the form I have a Zquery selecting everything out of a sample database table along with a bunch of calcuated fields (TFloatField; TCurrencyField). The OnCalcFields event of the query runs fine and all field values are set.
However, when i try to loop over the dataset, I consistently get a 'List index out of bounds (62893)' exception, though i am well within the field count limit (the first calculated field of about 14).
Snippet:
gd is a TStringGrid, ZQuery4 is a TZQuery
while not ZQuery4.Eof do
begin
row := row + 1;
gd.Cells[0, row] := IntToStr(gd.Row);
gd.Cells[1, row] := ZQuery4pid.Value; //Known column
gd.Cells[2, row] := FormatFloat('0.00', ZQuery4area.Value); //known column
for i := 3 to ZQuery4.FieldCount - 1 do
begin
field := Zquery4.Fields[i]; //crashes here when accessing the first calculated field.
if field.IsNull
then gd.Cells[i, row] := ''
else gd.Cells[i, row] := field.AsString;
end;
end;
The bizarre thing is that if i connect a DBGrid to the query it works fine. Any ideas?
What happens when gd.cells[x,row] exceeds the number of rows you have set in the string grid? Probably that's your error. If you set your stringgrid to have 62000 rows, great, that's your error. Otherwise, I suspect that you're hitting a limit.
I always used to have my string grid row count grow like this, with logic after row=row+1:
if gd.RowCount<=row then gd.RowCount := row+1;
If however you really are getting this error at 60k+ stringgrid rows, it is possible that instead what is happening is you are hitting a string grid row length limit.
Since you haven't obviously posted ALL your code, it's hard to know what sets the row count in the string grid where, and how it grows.
In the case that you've hit a limit beyond which a StringGrid no longer operates, I suggest you drop StringGrid and use ExgridView or some other virtual gridview that can handle a very very large amount of data.
I seem to have stumbled across at least a workaround:
changing
gd.Cells[i, row] := field.AsString;
to
gd.Cells[i, row] := field.DisplayText;
seems to have solved the problem.

Resources