User Tools

Site Tools


vba:functions:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
vba:functions:index [28.02.2014 09:19:17]
127.0.0.1 external edit
vba:functions:index [29.06.2016 10:56:17]
yaslaw
Line 1: Line 1:
 +~~DISCUSSION:​off~~
 +~~NOCACHE~~ ​
 +<​const>​ns=%NAMESPACE%</​const>​
 ======Functions====== ======Functions======
 {{:​vba:​functions:​functions.bas|}} {{:​vba:​functions:​functions.bas|}}
Line 18: 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=ns,​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 28: Line 31:
   hidejump;   hidejump;
  }}  }}
 +
 +
 +
  
  
 ===== VBA Funktionen ===== ===== VBA Funktionen =====
  
-==== char2unicode ​==== +==== concat() ​==== 
-<code vb char2unicode.bas>+Ist vor allem in Queries sehr angenehm, um mehrere Felder zu einem String zu kombinieren 
 +<code vb concat.bas>
 '/** '/**
-' * Copyright mpl by ERB software | http://​wiki.yaslaw.info +' * Fügt mehrere Elemente zu einem String zusammen 
-' * +' * @param  ​ParamArray ​     Die verschiedenen Elemente 
-' * Wandelt ein Charakter in ein Unicode +' * @return String
-' * @example: char2unicode("​€"​) -> '​\u20AC'​ +
-' * @param  ​String(1) ​  ​Charakter,​ der gewandelt werden soll +
-' * @return String ​     ​Unicode+
 ' */ ' */
-Private ​Function ​char2Unicode(ByVal iChar As String) As String +Public ​Function ​concat(ParamArray items() ​As Variant) As String 
-    ​char2Unicode ​Hex(AscW(iChar)) '​Hex-Wert ermitteln +    ​concat ​Join(itemsEmpty)
-    char2Unicode = "​\u"​ & String(4 - Len(char2Unicode)"​0"​& char2Unicode+
 End Function End Function
 </​code>​ </​code>​
  
-==== unicode2char ==== + 
-<code vb unicode2char.bas>​ +
-'/** +
-' * Copyright mpl by ERB software | http://​wiki.yaslaw.info +
-' * +
-' * Wandelt ein Unicode in ein Charakter +
-' * @example: unicode2char("​\u20AC"​) -> '​\€'​ +
-' * @param ​ String ​     Unicode +
-' * @return String ​     Char +
-' */ +
-Private Function unicode2Char(ByVal iUnicode As String) As String +
-    unicode2Char = ChrW(replace(iUnicode,​ "​\u",​ "&​h"​)) +
-End Function +
-</​code>​+
  
 ====replaceA()==== ====replaceA()====
 Mehrere Replace auf einmal ausführen Mehrere Replace auf einmal ausführen
-<code vb truncDate.bas>+<code vb replacea.bas>
 '/** '/**
 ' * Copyright mpl by ERB software | http://​wiki.yaslaw.info ' * Copyright mpl by ERB software | http://​wiki.yaslaw.info
Line 224: 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 
-'*/ 
-Public Function greatest(ParamArray items() As Variant) As Variant 
- Dim item As Variant 
- For Each item In items 
- If item > 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 
-'*/ 
-Public Function least(ParamArray items() As Variant) As Variant 
- Dim item As Variant 
- least = items(LBound(items)) 
- For Each item In items 
- If item < 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 345: 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>​
Line 418: Line 263:
 </​code>​ </​code>​
  
-====getActiveWinUser()==== 
-<code vb getActiveWinUser.bas>​ 
-'/** 
-' * Copyright mpl by ERB software | http://​wiki.yaslaw.info 
-' *  
-' * Gibt den aktuellen Windows-user zurück 
-' * @return <​String>​ 
-' */ 
-Public Function getActiveWinUser() 
- Dim objNet As Object 
-On Error Resume Next 
-  
- getActiveWinUser = "​NA"​ 
- Set objNet = CreateObject("​WScript.NetWork"​) 
- If Err.Number = 0 Then getActiveWinUser = objNet.UserName 
-  
- Set objNet = Nothing 
-End Function 
-</​code>​ 
  
 ====replaceUmlaute()==== ====replaceUmlaute()====
vba/functions/index.txt · Last modified: 29.06.2016 10:56:17 by yaslaw