title: Where am I missing a 'Return' statement in this VB.NET function?
body: <p>I am getting the error</p>
  
  <blockquote>
    <p>Function 'Login' doesn't return a value on all code paths. Are you missing a 'Return' statement?</p>
  </blockquote>
  
  <p>which I understand to a certain extent from viewing various questions on Stack&nbsp;Overflow. My confusion is that I have a return value for all code paths - don't I?</p>
  
  <pre><code>Public Function Login(Username As String, Password As Integer) As Integer
  
      Dim tableAdapter As New AcquisitionPortalDataSetTableAdapters.ITVF_LoginLogoutTableAdapter
      Dim dt As DataTable = tableAdapter.GetData(Username, Convert.ToInt32(Password))
  
      Try
          If dt IsNot Nothing AndAlso dt.Rows.Count &gt; 0 Then
              For Each dr In dt.Rows
                  If dr("LAN").ToString = Username AndAlso Convert.ToInt32(dr("Code")) = Password Then
                      GlobalVariables.iUserType = Convert.ToInt32(dr("Code"))
                      GlobalVariables.iUserID = Convert.ToInt32(dr("ID"))
                      Return 1
                  Else
                      Return 0
                  End If
              Next
          Else
              Return 0
          End If
      Catch
          Return 0
      End Try
  
  End Function
  </code></pre>
  
  <p>I've gone over this many times and each statement can be evaluated as far as I can tell. Can anyone advise otherwise, ideally with a brief explanation if possible, so I understand for the future?</p>