This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vba:functions:index [07.10.2014 14:17:20] yaslaw |
vba:functions:index [29.06.2016 10:56:17] (current) yaslaw |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~NOCACHE~~ | + | ~~DISCUSSION:off~~ |
+ | ~~NOCACHE~~ | ||
+ | <const>ns=%NAMESPACE%</const> | ||
======Functions====== | ======Functions====== | ||
{{:vba:functions:functions.bas|}} | {{:vba:functions:functions.bas|}} | ||
Line 19: | Line 21: | ||
===== Funktionen mit eigener Seite ===== | ===== Funktionen mit eigener Seite ===== | ||
{{pagequery> | {{pagequery> | ||
- | @vba:functions: *; | + | ^vba:functions:(?!index)[^:]+(?::index)?$; |
- | filter=id:vba:functions:[^:]+(?::index|)$,^id:vba:functions:index; | + | fullregex; |
- | sort=title; | + | sort=ns:asc,title:asc; |
display={title}; | display={title}; | ||
- | snippet=plain,all,w30; | + | snippet=plain,999999,l1; |
bullet=square; | bullet=square; | ||
fontsize=100%; | fontsize=100%; | ||
Line 29: | Line 31: | ||
hidejump; | hidejump; | ||
}} | }} | ||
+ | |||
+ | |||
+ | |||
Line 210: | Line 215: | ||
isClassModul = (Application.VBE.ActiveVBProject.VBComponents(tn).name) = tn | isClassModul = (Application.VBE.ActiveVBProject.VBComponents(tn).name) = tn | ||
Err.Clear | Err.Clear | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====bitComp()==== | ||
- | MS Access kennt für SQL-Statements kein Bit Vergleich. Mittels dieser Funktion kann man das im SQL | ||
- | trotzdem anwenden. Die Funktion kann aber auch normal innerhalb von VB verwednet werden. | ||
- | <code vb bitComp.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * Bit Comparison | ||
- | ' * geeignet für MS Access SQL-Statements | ||
- | ' * @example: Alle User mit Schreibrecheten gem. CHMOD hat | ||
- | ' * SELECT * FROM [user] WHERE BITCOMP([rigths], 2) | ||
- | ' * @param Integer | ||
- | ' * @param Integer | ||
- | ' * @return Boolean | ||
- | ' */ | ||
- | Public Function bitComp(ByVal iBytes As Integer, ByVal iBit As Integer) As Boolean | ||
- | bitComp = (iBytes And iBit) | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====greatest()==== | ||
- | Analog zu max(). Jedoch mit mehreren Werten | ||
- | <code vb greatest.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * Gibt den Grössten aus einer unbestimmten Menge von Werten zurück | ||
- | ' * @param Keine Objekte | ||
- | ' * @return Grösster Wert | ||
- | ' * @example greatest("Hallo Welt", 42, "Mister-X") -> Mister-X | ||
- | '*/ | ||
- | Private Function greatest(ParamArray iItems() As Variant) As Variant | ||
- | greatest = iItems(UBound(iItems)) | ||
- | Dim item As Variant: For Each item In iItems | ||
- | If Nz(item) > Nz(greatest) Then greatest = item | ||
- | Next item | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====least()==== | ||
- | Analog zu min(). Jedoch mit mehreren Werten | ||
- | <code vb least.bas> | ||
- | '/** | ||
- | ' * Gibt den Kleinsten aus einer unbestimmten Menge von Werten zurück | ||
- | ' * @param Keine Objekte | ||
- | ' * @return Grösster Wert | ||
- | ' * @example least("Hallo Welt", 42, "Mister-X") -> 42 | ||
- | '*/ | ||
- | Private Function least(ParamArray iItems() As Variant) As Variant | ||
- | least = iItems(LBound(iItems)) | ||
- | Dim item As Variant: For Each item In iItems | ||
- | If Nz(item) < Nz(least) Then least = item | ||
- | Next item | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====getMax()==== | ||
- | <code vb getMax.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * Gibt den Höheren von 2 Werten zurück | ||
- | ' * @param Variant Wert 1 | ||
- | ' * @param Variant Wert 2 | ||
- | ' * @return Variant der Grössere Wert | ||
- | ' */ | ||
- | Public Function getMax(ByVal iValue1 As Variant, ByVal iValue2 As Variant) As Variant | ||
- | If iValue1 > iValue2 Then | ||
- | getMax= iValue1 | ||
- | Else | ||
- | getMax= iValue2 | ||
- | End If | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====getMin()==== | ||
- | <code vb getMin.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * Gibt den Tieferen von 2 Werten zurück | ||
- | ' * @param Variant Wert 1 | ||
- | ' * @param Variant Wert 2 | ||
- | ' * @return Variant der Kleinere Wert | ||
- | ' */ | ||
- | Public Function getMin(ByVal iValue1 As Variant, ByVal iValue2 As Variant) As Variant | ||
- | If iValue1 < iValue2 Then | ||
- | getMin= iValue1 | ||
- | Else | ||
- | getMin= iValue2 | ||
- | End If | ||
End Function | End Function | ||
</code> | </code> | ||
Line 330: | Line 241: | ||
End If | End If | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====firstValue()==== | ||
- | <code vb firstValue.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * gibt den ersten Eintrag der nicht NULL ist zurück. | ||
- | ' * Ist sehr gut geeignet um aus Queries zuzugreiffen | ||
- | ' * Die Funktion funktioniert auch mit Objekten | ||
- | ' * @return Variant | ||
- | ' * @example: | ||
- | ' * ?firstValue(null, null,13,14, null) //Rückgabewert 13 | ||
- | ' */ | ||
- | Public Function firstValue(ParamArray items() As Variant) As Variant | ||
- | For Each firstValue In items | ||
- | If Not IsNull(firstValue) Then Exit For | ||
- | Next | ||
- | End Function | ||
- | </code> | ||
- | |||
- | ====find_in_set()==== | ||
- | Analog zu MySQL FIND_IN_SET(). Kann in Access vor allem bei nichtnormalisierten Tabellen verwendet werden | ||
- | <code vb find_in_set.bas> | ||
- | '/** | ||
- | ' * Copyright mpl by ERB software | http://wiki.yaslaw.info | ||
- | ' * | ||
- | ' * Analog zu MySQL FIND_IN_SET() | ||
- | ' * Kann in Access vor allem bei nichtnormalisierten Tabellen verwendet werden | ||
- | ' * @param String Element das gesucht wird | ||
- | ' * @param String Das Set von Elementen, mit Komma getrennt | ||
- | ' * @return Integer oder False | ||
- | ' * @example If find_in_set("d", "a,b,c,d") Then ... | ||
- | ' * @example SELECT ... WEHRE find_in_set('d', field1) | ||
- | ' */ | ||
- | Public Function find_in_set(ByVal iSearch As String, ByVal iSet As String) As Variant | ||
- | Dim parts() As String | ||
- | Dim index As Integer | ||
- | On Error GoTo Err_Handler | ||
- | find_in_set = False | ||
- | parts = split(iSet, ",") | ||
- | For index = 0 To UBound(parts) | ||
- | If Trim(parts(index)) = iSearch Then | ||
- | find_in_set = index + 1 | ||
- | Exit For | ||
- | End If | ||
- | Next index | ||
- | Exit Function | ||
- | Err_Handler: | ||
- | find_in_set = False | ||
End Function | End Function | ||
</code> | </code> |