Skip to content

Commit 1a07a0b

Browse files
committed
Improvements
1 parent 5b6eced commit 1a07a0b

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/UDFunctions.cls

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Option Explicit
1818
' GENERAL INFO:
1919
' Class module developed to provide samples of user defined functions (UDF).
2020

21+
Private Const Apostrophe As String = "'"
2122
Public Function GCD(ByRef aValues As Variant) As Long 'Expected an array
2223
Dim t As Long
2324
Dim u As Long
@@ -105,3 +106,25 @@ Private Function StringTodblArray(ByRef StringArray() As String) As Double()
105106
Next i
106107
StringTodblArray = tmpResult
107108
End Function
109+
''' <summary>
110+
''' List is expected to be an array. The last element will be used as
111+
''' the concatenation string.
112+
''' </summary>
113+
Public Function Concat(List As Variant) As String
114+
Dim startIdx As Long
115+
Dim endIdx As Long
116+
Dim i As Long
117+
Dim tmpResult As String
118+
Dim joinString As String
119+
120+
startIdx = LBound(List)
121+
endIdx = UBound(List)
122+
joinString = MidB$(List(endIdx), 3, LenB(List(endIdx)) - 4)
123+
tmpResult = MidB$(List(startIdx), 3, LenB(List(startIdx)) - 4)
124+
For i = startIdx + 1 To endIdx - 1
125+
tmpResult = tmpResult & _
126+
joinString & _
127+
MidB$(List(i), 3, LenB(List(i)) - 4)
128+
Next i
129+
Concat = Apostrophe & tmpResult & Apostrophe
130+
End Function

src/VBAexpressions.cls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ Private Sub Class_Initialize()
275275
'@--------------------------------------------------------------------
276276
' Populate building UDFs
277277
Dim UDFnames() As Variant
278-
UDFnames() = Array("GCD", "DET")
279-
DeclareUDF UDFnames, "UserDefFunctions" 'Declare the Greatest Common Divisor and matrix Determinant functions
280-
'defined in the UDfunctions class module. This need
281-
'an instance in the VBAcallBack class module.
278+
UDFnames() = Array("GCD", "DET", "Concat")
279+
DeclareUDF UDFnames, "UserDefFunctions" 'Declare the Greatest Common Divisor, matrix Determinant and
280+
'the string concatenation functions defined in the UDfunctions
281+
'class module. This needan instance in the VBAcallBack class module.
282282
'@--------------------------------------------------------------------
283283
' Initialize error messages
284284
InitializeErrHandler
@@ -1955,7 +1955,7 @@ Private Function GetTokenInfo(ByRef expression As String) As TokenInfo
19551955
If tmpResult.Position = -1 Then 'Missing arithmetic opetarators.
19561956
If expression Like "*[=<>&|$]*" Then 'Try with logical operators.
19571957
tmpResult = GetLCOpInfo(expression)
1958-
tmpResult.LogicalToken = True
1958+
tmpResult.LogicalToken = Not expression Like "'*[=<>&|$]*'"
19591959
Else
19601960
tmpResult.Position = -1
19611961
If expression Like "*[Tt][Rr][Uu][Ee]" Then

testing/tests/Test runner.xlsm

9.14 KB
Binary file not shown.

0 commit comments

Comments
 (0)