VB.NET "If...Then" syntax without "Then"

I’ve run into a problem after converting another project to Mercury from VB.NET. This is a project that contains generated classes using LLBLGen, and it will not compile. Here’s an example of the code that won’t compile - notice there is no “Then” at the end of the first line:

If ((fields(0).ExpressionToApply Is Nothing) OrElse (Not expressionToExecute Is Nothing))
	fields(0).ExpressionToApply = expressionToExecute
End If

The error is: ‘(E1) “then” expected, got identifier’.

However, it turns out that code like this is completely valid in VB.NET - “Then” is apparently optional if it is multi-line. I had no idea!

I’ve never done it, but I might be able to change LLBLGen’s code generator to add the “Then”, but I’d rather not if I don’t have to. (In this particular project this syntax is used A LOT.) Is this something that can be changed so that it is consistent with VB.NET’s allowed syntax?

–Avonelle

1 Like

Thanks, logged as bugs://85457

One from the learn-something-new-every-day department :wink:

bugs://85457 got closed with status fixed.

Ok, I learned something new today too …

1 Like