Skip to content

Commit 493cdad

Browse files
committed
Update VBAexpressions.cls
1 parent 331dee5 commit 493cdad

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/VBAexpressions.cls

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -811,18 +811,22 @@ Private Function CastCase(ByRef Expression As String) As String
811811
End Function
812812

813813
Private Function CastOPtype(ByRef strOperand As String, ByRef Negate As Boolean) As Variant
814-
If IsLiteralString(strOperand) Then 'Literal strings like ['string']
815-
CastOPtype = FormatLiteralString(strOperand)
816-
Else
817-
If AscW(strOperand) < 58 Then
818-
CastOPtype = CDbl(strOperand)
814+
If strOperand <> vbNullString Then
815+
If IsLiteralString(strOperand) Then 'Literal strings like ['string']
816+
CastOPtype = FormatLiteralString(strOperand)
819817
Else
820-
If Not Negate Then
821-
CastOPtype = -1 * CBool(strOperand)
818+
If AscW(strOperand) < 58 Then
819+
CastOPtype = CDbl(strOperand)
822820
Else
823-
CastOPtype = -1 * (Not CBool(strOperand))
821+
If Not Negate Then
822+
CastOPtype = -1 * CBool(strOperand)
823+
Else
824+
CastOPtype = -1 * (Not CBool(strOperand))
825+
End If
824826
End If
825827
End If
828+
Else
829+
CastOPtype = strOperand
826830
End If
827831
End Function
828832

@@ -2144,12 +2148,9 @@ Private Function IsLikeSciNot(ByRef Chars As String) As Boolean
21442148
End Function
21452149

21462150
Private Function IsLiteralString(ByRef aString As String) As Boolean
2147-
Dim LenStr As Long
2148-
2149-
LenStr = LenB(aString)
2150-
If LenStr Then
2151+
If aString <> vbNullString Then
21512152
If AscW(aString) = 39 Then 'Apostrophe
2152-
IsLiteralString = (InStrB(3, aString, d_Apostrophe) = LenStr - 1)
2153+
IsLiteralString = (InStrB(3, aString, d_Apostrophe) = LenB(aString) - 1)
21532154
Else
21542155
IsLiteralString = False
21552156
End If

0 commit comments

Comments
 (0)