Oct-06-2019, 08:44 AM
(Oct-06-2019, 06:51 AM)Gribouillis Wrote: What about ++++45 or -+54 ? Here is a corrected version
Glad to inform that your revised function works nicely, giving correct results for all our test strings, even if carrying + sign. However, with negative signed string, it still gives AssertionError.
For "++++45" & " -+54", VBA's Val() function returns 0 in both cases.
It is seen that for pure number strings, even if signed, python's built-in eval() function provides results similar to those by VBA's Val() function. For example:
print(eval("45")) #>>>45 print(eval("+4.5")) #>>>4.5 print(eval("-4.5")) #>>>-4.5However, for mixed strings like "4.5ABC" or " 2 45 7 ", eval() throws error.
A.D.Tejpal