locked
if COndition in WIth Keyword RRS feed

  • Question

  • User1655374113 posted

    Hello,

    Can we use If condition in With Keyword ? I am adding items to the class using with in VB.Net. I want to validate one condition before adding. I want to validate isActive with if condition in below Code.

        For i As Integer = 0 To currWf.Tables(0).Rows.Count - 1
          wfChartDataItemCollection.Add(New WfChartDataItem() With { _
                                      .Index = Convert.ToInt32(currWf.Tables(0).Rows(i)("StatusID").ToString()), _
                                      .isActive = True, _
                                      .Title = Convert.ToInt32(currWf.Tables(0).Rows(i)("RoleID").ToString()), _
                                      .Description = currWf.Tables(0).Rows(i)("Description").ToString() _
                                      })
        Next



    Friday, January 18, 2013 11:48 AM

Answers

  • User281315223 posted

    Sure!

    If your isActive property is a boolean value (meaning it can be set to either True or False) then you can also set it equal to a comparison that you would perform in an If Statement : 

    .isActive = (variableA > variableB)   

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2013 11:59 AM