What's wrong with this: "If DoctorBindingSource.Current("StreetAddressLine2") <> "" Then"

Visual Basic 2005 Express Edition didn't like the "<>" in the statement below:

If DoctorBindingSource.Current("StreetAddressLine2") <> "" Then

DoctorTextBox.Text = DoctorTextBox.Text & DoctorBindingSource.Current("StreetAddressLine2") & vbNewLine

End If

It didn't like it when I substituted "DBnull", either.



Answer this question

What's wrong with this: "If DoctorBindingSource.Current("StreetAddressLine2") <> "" Then"

  • jmarkel

    hi,

    assign it to variable then use the variable instead, the bindingsource.current shouldn't be used like that

    best regards



  • Y-SW

    hi,

    then use if not work is nothing then



  • Roger Haight

    >Assign it to variable then use the variable instead, the bindingsource.current shouldn't be used >like that

    Dim work as string

    work = DoctorBindingSource.Current("StreetAddressLine2")

    I got this error "Conversion from type 'DBNull' to type 'String' is not valid.".


  • roypython

    If DoctorBindingSource.Current("StreetAddressLine2") <> Nothing Then

    DoctorTextBoxText(Color.MediumBlue, DoctorBindingSource.Current("StreetAddressLine2") & vbNewLine)

    End If

    I got this error message: "Operator '<>' is not defined for type 'DBNull' and 'Nothing'."


  • What's wrong with this: "If DoctorBindingSource.Current("StreetAddressLine2") <> "" Then"