score:1

Accepted answer
 If searchtype = "withdatetime" Then
        Dim locs As New crimemsapslocationDataContext
        Dim giveloc = From locations In locs.crimelocations _
                      Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Convert.ToDateTime(startdate) And locations.DATE_COMTD <= Convert.ToDateTime(enddate)) _
                      And (locations.gettimecom >= starttime And locations.gettimecom <= endtime) _
                      Select locations
        Return giveloc.ToList
    ElseIf searchtype = "withdate" Then
        Dim locs As New crimemsapslocationDataContext
        Dim giveloc = From locations In locs.crimelocations _
                      Where locations.INCIDENTTYPE = crime And (locations.DATE_COMTD >= Convert.ToDateTime(startdate) And locations.DATE_COMTD <= Convert.ToDateTime(enddate)) _
                      Select locations

        Return giveloc.ToList
    ElseIf searchtype = "without" Then
        Dim locs As New crimemsapslocationDataContext
        Dim giveloc = From locations In locs.crimelocations _
                      Where locations.INCIDENTTYPE = crime _
                      Select locations

        Return giveloc.ToList
    End If
 // if none of the if-else conditions are met your code goes straight to here and there is not return statement
    Return null; // this fixes it.

Related Query

More Query from same tag