From: "WindAndWaves" <ac****@ngaru.com>
Subject: Re: why use a class module
Date: Wednesday, 26 May 2004 6:25 p.m.
this is my code that takes a while to run:
I have put in the checks, because some fields may not contain proper date
fields or what have you.
Function fsimdat(Optional VFRO1, Optional VUNT1, Optional VFRO2, Optional
VUNT2) As Byte
'works out whether or not two date periods coincide
'0 = do not coincide
'1 = coincide
'2 = error
on error GoTo err
'--------------------------------------
Dim Fro1 As Date
Dim Unt1 As Date
Dim Fro2 As Date
Dim Unt2 As Date
'--------------------------------------
If IsNull(VFRO1) = True Or IsDate(VFRO1) = False Then GoTo data_error
Else Fro1 = VFRO1
If IsNull(VUNT1) = True Or IsDate(VUNT1) = False Then GoTo data_error
Else Unt1 = VUNT1
If IsNull(VFRO2) = True Or IsDate(VFRO2) = False Then GoTo data_error
Else Fro2 = VFRO2
If IsNull(VUNT2) = True Or IsDate(VUNT2) = False Then GoTo data_error
Else Unt2 = VUNT2
If Fro1 > Unt1 Or Fro2 > Unt2 Then GoTo data_error
If Fro1 = Unt1 Then Unt1 = Unt1 + 1
If Fro2 = Unt2 Then Unt2 = Unt2 + 1
'----------------------------'----------------------------
fsimdat = 2
'----------------------------'----------------------------
'1: |----|
'2: |---|
If Unt2 < Fro1 Then GoTo UnCoinciDe
'----------------------------'----------------------------
'1: |----|
'2: |---|
If Unt1 < Fro2 Then GoTo UnCoinciDe
'----------------------------'----------------------------
'1: |----|
'2: |-------|
If Fro1 >= Fro2 And Unt1 <= Unt2 Then GoTo CoinciDe
'----------------------------'----------------------------
'1: |---------|
'2: |-------|
If Fro2 >= Fro1 And Unt2 <= Unt1 Then GoTo CoinciDe
'----------------------------'----------------------------
'1: |------|
'2: |-----|
If Fro1 >= Fro2 And Unt1 >= Unt2 Then GoTo CoinciDe
'----------------------------'----------------------------
'1: |----|
'2: |-----|
If Fro1 <= Fro2 And Unt1 <= Unt2 Then GoTo CoinciDe
data_error:
fsimdat = 3
xit:
Exit Function
CoinciDe:
fsimdat = 1
GoTo xit
UnCoinciDe:
fsimdat = 0
GoTo xit
err:
fsimdat = 2
Resume Next
End Function
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004