これが私のコードです
<WebMethod()> _
Public Function getlocationsbypro(searchtype As String, crime As String, proid As String, startdate As String, enddate As String, starttime As String, endtime As String) As List(Of crimelocation)
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
End Function
しかし、コンパイルすると、すべての if ステートメントに return ステートメントがあるにもかかわらず、関数がすべてのコード パスで値を返さないと表示されます。上記のエラーは表示されません。