testString is of variable type string.
testString=“ABC”
Msgbox(IIf(DateTime.TryParse(testString,dtTest),cdate(testString),testString)) → Got runtime exception. Cannot convert “ABC” to date type.
yah thats correct but along with that condition we have made this casting like converting a string to datetime, which is why throwing error
DateTime.TryParse(testString,dtTest),cdate(testString),testString)
Fine
as these two are same they get matched with dateformat and it goes to TRUE part of if condition
IF(DateTime.TryParse(testString,dtTest,cdate(testString)),testString.ToString,“anyvalue”)
No, If you run this into two modules for example… DateTime.TryParse(testString,dtTest), it will give value as False for using “ABC” but in case of “12/11/2019” it gives true value.
hmm… then obvious it would fail right being unmatched and if the testString has any date value as string then it would get matched and goes to the TRUE part of IF condition @Lakshay_Verma