This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vba:functions:isnothing [08.07.2014 14:39:33] yaslaw [[VBA] isNothing()] |
vba:functions:isnothing [05.02.2021 14:21:58] (current) yaslaw |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <const> | ||
+ | version=1.0.3 | ||
+ | vdate=03.09.2018 | ||
+ | fname=udf_isnothing.bas | ||
+ | ns=%NAMESPACE% | ||
+ | fpath=/vba/functions | ||
+ | </const> | ||
====== [VBA] isNothing() ====== | ====== [VBA] isNothing() ====== | ||
Prüft ob allgemein etwas in einer Variable ist. Fast also mehrere mögliche Leerprüfungen zusammen | Prüft ob allgemein etwas in einer Variable ist. Fast also mehrere mögliche Leerprüfungen zusammen | ||
Line 10: | Line 17: | ||
*Nicht initializierter Array | *Nicht initializierter Array | ||
- | {{:vba:functions:udf_isnothing.bas|download udf_isNothing.bas}} | + | ==Version %%version%% %%vdate%%== |
+ | {{%%fname%%|Download %%fname%% (V-%%version%%)}} | ||
===== Definition ===== | ===== Definition ===== | ||
Line 34: | Line 42: | ||
True</code> | True</code> | ||
- | === Code === | + | ===== Code ===== |
- | <code vb udf_isNothing.bas>'------------------------------------------------------------------------------- | + | <source '%%fpath%%/%%fname%%' vb> |
- | 'File : udf_isNothing.bas | + | |
- | ' Copyright mpl by ERB software | + | |
- | ' All rights reserved | + | |
- | ' http://wiki.yaslaw.info/dokuwiki/doku.php/vba/cast/strtodate | + | |
- | 'Environment : VBA 2007 + | + | |
- | 'Version : 1.0.1 | + | |
- | 'Name : _isNothing | + | |
- | 'Author : Stefan Erb (ERS) | + | |
- | 'History : 30.04.2014 - ERS - Creation | + | |
- | '------------------------------------------------------------------------------- | + | |
- | Option Explicit | + | |
- | + | ||
- | '/** | + | |
- | ' * Prüft, ob eine Variable Null, Empty, Nothing, Leerstring, leerer Array etc ist | + | |
- | ' * | + | |
- | ' * boolean = isNothing(object) | + | |
- | ' * boolean = isNothing(vaule) | + | |
- | ' * | + | |
- | ' * @param Variant Variable die geprüft werden soll | + | |
- | ' * @return Boolean | + | |
- | ' */ | + | |
- | Public Function isNothing(ByRef iValue As Variant) As Boolean | + | |
- | isNothing = True | + | |
- | Select Case TypeName(iValue) | + | |
- | Case "Nothing", "Empty", "Null": Exit Function | + | |
- | Case "Collection", "Dictionary": If iValue.count = 0 Then Exit Function | + | |
- | Case "String": If Len(Trim(iValue)) = 0 Then Exit Function | + | |
- | Case "Iterator": If Not iValue.isInitialized Then Exit Function | + | |
- | '//TODO: weitere Spezialfälle | + | |
- | Case Else: | + | |
- | If IsArray(iValue) Then | + | |
- | On Error Resume Next | + | |
- | Dim dummy As Variant: dummy = iValue(LBound(iValue)) | + | |
- | If Err.Number <> 0 Then Exit Function | + | |
- | End If | + | |
- | End Select | + | |
- | isNothing = False | + | |
- | End Function</code> | + |