This happens a lot and I have a small test case that does it every time.
Private Class MyCustomer
Public Property Value As String
End Class
Public Class ExcelLineRecordClass
Public Property LineNumber As Integer
Public Property imported As Boolean
End Class
Dim ExcelRecord As New ExcelLineRecordClass
Dim lCell As New MyCustomer
If lCell Is Nothing Then
ExcelRecord.imported = False
Else
ExcelRecord.imported = If(Debugger.IsAttached, lCell.Value.ToString = "X" Or lCell.Value.ToString = "Y", lCell.Value.ToString = "Y")
End If
When you try to preview turning the if into a Ternary, it crashes. There are a lot of other case where it also fails but they all seem to involve a class. The following works
Dim ExcelRecord As Boolean
Dim lCell As New MyCustomer
If lCell Is Nothing Then
ExcelRecord = False
Else
ExcelRecord = If(Debugger.IsAttached, lCell.Value.ToString = "X" Or lCell.Value.ToString = "Y", lCell.Value.ToString = "Y")
End If
This happens a lot and I have a small test case that does it every time.
When you try to preview turning the if into a Ternary, it crashes. There are a lot of other case where it also fails but they all seem to involve a class. The following works