|
Post by Roger Cabo on Jul 15, 2022 16:38:58 GMT 1
Hi,
today I tried to create a struct with a date variable. When trying to use the the variable I got en array error. Seems type.Date is not defined..
Type TP_Config_Struct GültigAb As Date EndType
Global DB_TermZeitenSet(10) As TP_Config_Struct Dim d As Date d = DB_TermZeitenSet(0).GültigAb
Did you got the same error? Thank you..
|
|
|
Post by (X) on Jul 15, 2022 16:42:55 GMT 1
This may help.
Check out known issues with Date type in the GFA help file: Type Command.
// This code contains an error:
Type TDateArray Dat(10) As Date ' array of type Date EndType Dim Dt As TDateArray Dt.Dat(0) = Now ' assignment ok Trace Dt.dat(0) ' Error: INTERNAL: Array(Type)
// Solution:
Type TDateArray Dat(10) As Double ' array of type Double EndType Dim Dt As TDateArray Dt.Dat(0) = Now ' assignment ok Trace Dt.Dat(0) ' Ok
|
|
|
Post by Roger Cabo on Jul 16, 2022 15:50:00 GMT 1
Thank you!
I will have a look at the old German manual next time! :-)
|
|
|
Post by dragonjim on Jul 16, 2022 17:00:41 GMT 1
Just a quick addition to (X)'s post above.
The workaround from the help file is great as a practical way of getting around the Date bug in a Type; you just need to keep in mind that some of the commands such as Print and Trace will not recognise the Double as a Date and will, therefore, not display the value as you want it. This is shown best by the following code:
Local a As Date, b As Double, c As Int32 a = Now : b = Now : c = Int(Now) Print a // Prints in date format Print b // Prints double, not date... Print DateTime$(b) // ...so you need DateTime$ Print c // Prints integer, not date... Print Date$(c) // ...so you need Date$
Just something to keep in mind.
|
|
|
Post by Roger Cabo on Jul 16, 2022 18:55:52 GMT 1
Thank you!
In the past I have use all this stuff extremely often.
Eg: To find put how many days a month have I use:
Dim d As Date : Dim Mo%=7 // July MsgBox Day(DmyToDate(0, Mo% + 1, 2022)) //31
|
|