[dba-Tech] On Odious Code

Stuart McLachlan stuart at lexacorp.com.pg
Tue Aug 3 17:00:36 CDT 2004


On 3 Aug 2004 at 16:54, Arthur Fuller wrote:

> A la Gustav, they didn't ask me either, but I would frankly prefer these
> constructs:
> 
> If Type(myVar) <> "Date" 'or better, <> vbaDate
> If Value(myVar) <> NULL
> If Type(myVar) <> "Numeric" 'or better, <> vbaNumeric
> 
> And while we're on it, would someone kindly provide examples of the
> correct use of IsEmtpy()? This one has always baffled me.
> 


Here's one. Without the "If IsEmpty()..." line, this function returns an error 
if called for the first time with no varInput:

Static Function StoredVariable(Optional varInput As Variant) As Variant
    Dim varStore As Variant

    'Initialise the variant if the function is called
    'the first time with no Input
    If IsEmpty(varStore) Then varStore = Null

    'Update the store if the Input is present
    If Not IsMissing(varInput) Then varStore = varInput

    'return the stored value
    StoredVariable = varStore
End Function

 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the dba-Tech mailing list