how to assign not null condition in vb.net?

10,101

You can do it a few ways, you could do:

Value <> Nothing

Or

If Not String.IsNullOrEmpty(JobEventAllDetailsSortnew.Item(value).EventText())

End If

To name a couple of ways.

http://msdn.microsoft.com/en-us/library/system.string.isnullorempty(v=vs.110).aspx

Share:
10,101
NarasimhaKolla
Author by

NarasimhaKolla

I work on mobile applications using Java, C#, VB and XML as the graphical front end. Interested in using Web Services for mobile applications

Updated on June 14, 2022

Comments

  • NarasimhaKolla
    NarasimhaKolla almost 2 years

    i am working on windows8 vb.net mobile application in that application i am checking not null conditions.here below i have attaching the code file.

    If JobEventAllDetailsSortnew.Item(value).EventText() IsNot Nothing _
    And JobEventAllDetailsSortnew.Item(value).ReasonCodeDesc() IsNot Nothing Then
        mEventNotes = "Event text: " + JobEventAllDetailsSortnew.Item(value).EventText() + _ 
                      "\nReason: " + JobEventAllDetailsSortnew.Item(value).ReasonCodeDesc()
    ElseIf JobEventAllDetailsSortnew.Item(value).EventText().Trim() IsNot Nothing Then
        mEventNotes = "Event text: " + JobEventAllDetailsSortnew.Item(value).EventText()
    Else
        mEventNotes = JobEventAllDetailsSortnew.Item(value).EventText().Trim() + _
                      "\n" + JobEventAllDetailsSortnew.Item(value).ReasonCodeDesc().Trim()
    End If
    

    Please give me any suggestion how to write not null conditions in vb.net?

  • Andrew Morton
    Andrew Morton almost 10 years
    You should use Value IsNot Nothing to check for not being Nothing.